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++/71394] New: -Werror=conversion-null identifies incorrect data member of member initializer list


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

            Bug ID: 71394
           Summary: -Werror=conversion-null identifies incorrect data
                    member of member initializer list
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mitchjcarlson at gmail dot com
  Target Milestone: ---

Created attachment 38632
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38632&action=edit
preprocessed file

In the below example, we can see that the error message produced from the
compiler incorrectly identifies a data member which is in violation of our
Werror. The current error message is misleading.

#include <cstddef>

struct ErrorConversionNullBug
{
    ErrorConversionNullBug()
        : n(NULL)
        , c('c')
    {}
    unsigned int n;
    const char c;
};

int main()
{
    ErrorConversionNullBug bug;
}

$ /opt/gcc/4.8.2/bin/g++48 -v -save-temps -Werror=conversion-null -o main
main.cpp
Using built-in specs.
COLLECT_GCC=/opt/gcc/4.8.2/bin/g++48
COLLECT_LTO_WRAPPER=/opt/gcc/4.8.2/libexec/gcc/i686-pc-linux-gnu/4.8.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/opt/gcc/4.8.2 --enable-languages=c,c++
--program-suffix=48 --with-as=/opt/binutils/2.24/bin/as24
--with-ld=/opt/binutils/2.24/bin/ld24
Thread model: posix
gcc version 4.8.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Werror=conversion-null' '-o' 'main'
'-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /opt/gcc/4.8.2/libexec/gcc/i686-pc-linux-gnu/4.8.2/cc1plus -E -quiet -v
-D_GNU_SOURCE main.cpp -mtune=generic -march=pentiumpro -Werror=conversion-null
-fpch-preprocess -o main.ii
ignoring nonexistent directory
"/opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/../../../../include/c++/4.8.2

/opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/../../../../include/c++/4.8.2/i686-pc-linux-gnu

/opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/../../../../include/c++/4.8.2/backward
 /opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/include
 /usr/local/include
 /opt/gcc/4.8.2/include
 /opt/gcc/4.8.2/lib/gcc/i686-pc-linux-gnu/4.8.2/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Werror=conversion-null' '-o' 'main'
'-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /opt/gcc/4.8.2/libexec/gcc/i686-pc-linux-gnu/4.8.2/cc1plus -fpreprocessed
main.ii -quiet -dumpbase main.cpp -mtune=generic -march=pentiumpro -auxbase
main -Werror=conversion-null -version -o main.s
GNU C++ (GCC) version 4.8.2 (i686-pc-linux-gnu)
        compiled by GNU C version 4.8.2, GMP version 5.1.1, MPFR version 3.1.1,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (GCC) version 4.8.2 (i686-pc-linux-gnu)
        compiled by GNU C version 4.8.2, GMP version 5.1.1, MPFR version 3.1.1,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 966073129663909613ddef5561ea5ee6
main.cpp: In constructor 'ErrorConversionNullBug::ErrorConversionNullBug()':
main.cpp:7:16: error: converting to non-pointer type 'unsigned int' from NULL
[-Werror=conversion-null]
         , c('c')
                ^
cc1plus: some warnings being treated as errors

$ lscpu
Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                0
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 63
Stepping:              2
CPU MHz:               2600.007
BogoMIPS:              5199.24
Virtualization:        VT-x

$ cat /proc/version
Linux version 2.6.32-573.8.1.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org)
(gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP Tue Nov 10
18:01:38 UTC 2015

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