== Steps to reproduce == #!/bin/sh # 1. Create the source file cat > 'bugpp.cpp' <<'/* EOF */' struct personal_data { char name [01]; char surname [01]; } const sc_me = { "Christopher", "Yeleighton" }; /* EOF */ # 2. Compile as C++ make 'bugpp' # 3. Compile as C mv 'bugpp.cpp' 'bug.c' make 'bug'
== Expected results (from gcc) == cc bug.c -o bug bug.c:4: warning: initializer-string for array of chars is too long bug.c:4: warning: (near initialization for ‘sc_me.name’) bug.c:5: warning: initializer-string for array of chars is too long bug.c:5: warning: (near initialization for ‘sc_me.surname’) == Actual results (from g++) == g++ bugpp.cpp -o bugpp bugpp.cpp:5: error: initializer-string for array of chars is too long bugpp.cpp:5: error: initializer-string for array of chars is too long == Essential differences == * The first line number should be 4 * g++ fails to indicate the failing data field == Why this is important == Ordinary bugs in error messages should be marked as "enhancement"; however, this one is particularly nasty. It is very difficult to identify the cause of error when compiling long data initialisation statements using g++ because the error message does not contain the line number or the position in the structure. == See also == * Bug 31158 == Version information == Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.4 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.4 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux Thread model: posix gcc version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux) -- Summary: initializer-string for array of chars is too long: which one? Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: giecrilj at stegny dot 2a dot pl GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45431