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

            Bug ID: 91964
           Summary: Wrong -Wint-in-bool-context warning for enum constant
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joerg.rich...@pdv-fs.de
  Target Milestone: ---

cat > t.cc <<EOF
enum Enum { A, B, C };

bool func()
{
  if( (int)C ) return true;                                    // 1
  if( (bool)C ) return true;                                   // 2
  if( static_cast<int>(C) ) return true;                       // 3
  if( static_cast<bool>(C) ) return true;                      // 4
  if( static_cast<bool>( static_cast<int>(C) ) ) return true;  // 5
  return false;
}
EOF

gcc -c -o t.cc.o t.cc -Wall

#### 

Gives: warning: enum constant in boolean context [-Wint-in-bool-context]

GCC 9.2 warns for all cases.
GCC 8.3 warns for case 2 & 4.

I think all warnings are wrong because nowhere is a enum constant in a boolean
context.

Enums 'A' and 'B' dont seem to trigger the warning.

Reply via email to