[Bug c++/49462] New: comparison of const bool and pointer does not yield an error

frederic.bron at m4x dot org gcc-bugzilla@gcc.gnu.org
Sat Jun 18 05:26:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49462

           Summary: comparison of const bool and pointer does not yield an
                    error
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: frederic.bron@m4x.org


The following code should produce the error "ISO C++ forbids comparison between
pointer and integer" when compiled with g++ -std=c++98 -pedantic-errors.
When the bool is not const or volatile of const volatile, the error is
produced. Only when bool is "only" const, the error is not produced.
Same problem with all comparison operators ==, !=, <, <=, >, >=.

int * pi=0;
bool const b=0;
pi==b;
b==pi;



More information about the Gcc-bugs mailing list