[Bug c++/62148] New: g++ does not catch signed/unsigned comparisons when run on a pre-processed source

aron at cohesity dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 15 01:02:00 GMT 2014


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

            Bug ID: 62148
           Summary: g++ does not catch signed/unsigned comparisons when
                    run on a pre-processed source
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aron at cohesity dot com

Created attachment 33332
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33332&action=edit
Source file that has signed/unsigned comparison

When a .cc file is compiled with -Wall flag, g++ is expected to emit warnings
when it sees a signed/unsigned integer comparison. However, I have seen
instances where g++ would catch the error when it is run on the .cc file, but
if the .cc is first preprocessed using 'g++ -E' and then the resulting
preprocessed source is compiled, no warning is emitted.

The problem seems to be due to the '#' directives emitted by the preprocessor.
To exemplify this, please see the source file chk.cc that is attached. Try
compiling it using 'g++ -Wall -c chk.cc'. It correctly emits out the
signed/unsigned comparison warning. However, introduce the following statement
at the beginning of this source file:

# 1 "chk.cc" 3 4

The above statement is similar to what is inserted when a .cc file is
preprocessed using 'g++ -E'. Anyways, after inserting the above statement, try
compiling again - now g++ will compile without emitting any warnings.



More information about the Gcc-bugs mailing list