This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86184] Conditional expression with omitted operand cannot use rvalue of type convertible to bool


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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Runtime test:

int j;
struct X {
  X() { j++; }
  operator bool() { return true; }
};

/* Only create X once.  */
bool b = X() ?: false;
bool b2 = X() ? X() : false;

int
main ()
{
  if (j != 3)
    __builtin_abort ();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]