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

            Bug ID: 88458
           Summary: Conditional expression where the second and third
                    operand are int and nullptr treated as ill-formed
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yaghmour.shafik at gmail dot com
  Target Milestone: ---

Given the following code

char* ch4 = true ? 0 : nullptr;

and compiling with the following flags:

-std=c++17

gcc produces the following diagnostic:

 error: operands to ?: have different types 'int' and 'std::nullptr_t'
    4 |   char* ch4 = true ? 0 : nullptr;
      |               ~~~~~^~~~~~~~~~~~~

Both clang and MSVC accepts this code w/o diagnostic, see godbolt:
https://godbolt.org/z/BraaEu

I believe according to http://eel.is/c++draft/expr.cond#7.5 this is
well-formed.

Reply via email to