https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94039

            Bug ID: 94039
           Summary: conditional operator fails to use proper overload
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: monstrefou at gmail dot com
  Target Milestone: ---

I believe the following program should compile but I get the error 
"operands to ?: have different types 'INT_WRAPPER' and 'std::nullptr_t'"

class INT_WRAPPER
{
    public:
        operator int*() { return m_int = nullptr; }
    private:
        int* m_int;
};

int main()
{ 
    true ? INT_WRAPPER() : nullptr;
}

>From my understanding neither type can't be implicitly converted to the other
type "target" as described in 7.6.16 paragraph 4

So it should do use overload resolution as per 7.6.16 paragraph 4

and operator?:(int*, int*) should be an available overload as per 12.7
paragraph 28

So in conclusion I think it this code should compile and the result type of the
conditional operator should be in* in this case

Reply via email to