Re: Re[4]: Using -Wall and -Woverloaded-virtual together changes the behaviour of the code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 27, 2018 at 5:12 PM, Vadim Zeitlin <vz-gcc@xxxxxxxxxxxx> wrote:
> On Tue, 27 Mar 2018 16:48:39 +0200 Mathieu Malaterre <malat@xxxxxxxxxx> wrote:
>
> MM> Using a mixed stretch with g++-mingw-w64-i686/sid here is what I see:
>
>  Hi Mathieu and thanks for testing this!
>
> MM> $ i686-w64-mingw32-g++ -c -std=c++17 -O2 -Wnonnull -Woverloaded-virtual -v 16795.cpp -o warn.o
> [...]
>
>  This is indeed exactly the same thing as I see too, including the warning
> and everything (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85091#c3).
>
> MM> COLLECT_GCC_OPTIONS='-c' '-std=c++1z' '-O2' '-Wnonnull'
> MM> '-Woverloaded-virtual' '-v' '-o' 'warn.o' '-shared-libgcc'
> MM> '-mtune=generic' '-march=pentiumpro'
> MM>  /usr/bin/i686-w64-mingw32-as -v -o warn.o /tmp/cc9O6U4l.s
> MM> GNU assembler version 2.28 (i686-w64-mingw32) using BFD version (GNU
> MM> Binutils) 2.28
> MM> COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/bin/
> MM> LIBRARY_PATH=/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/lib/../lib/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/lib/
> MM> COLLECT_GCC_OPTIONS='-c' '-std=c++1z' '-O2' '-Wnonnull'
> MM> '-Woverloaded-virtual' '-v' '-o' 'warn.o' '-shared-libgcc'
> MM> '-mtune=generic' '-march=pentiumpro'
> MM>
> MM> And then:
> MM>
> MM> $ objdump -d warn.o  | grep -A 2 test_main
> MM> 000001a0 <__Z9test_mainiPPc>:
> MM>  1a0: 31 c0                xor    %eax,%eax
> MM>  1a2: c3                    ret
>
>  But here it gives:
>
> % objdump -d warn.o  | grep -A 2 test_main
> 000001a0 <__Z9test_mainiPPc>:
>  1a0:   f0 83 05 4c 00 00 00    lock addl $0x1,0x4c
>  1a7:   01
>
> MM> So I suspect the difference is rather in binutils, mine is still:
> MM>
> MM> GNU assembler version 2.28 (i686-w64-mingw32) using BFD version (GNU
> MM> Binutils) 2.28
>
>  It's true that I'm using 2.29.1 (from Buster), but I'm not sure if this
> can explain the problem because I also see the wrong instruction in the
> assembly file (16795.s) if I add -save-temps to the compiler command line.
> And binutils doesn't affect this, does it?
>
>  The only other thing that might differ that I can think of seems to be
> completely unrelated, but, just in case it still matters: is your system
> a normal Linux installation or, like mine, a chroot inside one? Because
> I've tested this, from the beginning, in a Buster chroot on a Stretch
> system (on 2 different physical machines) and in a Sid chroot on a Jessie
> system (on yet another machine). I'm using chroot to isolate the tests, but
> could it be that gcc somehow misbehaves inside a chroot? Again, I realize
> that there is no good reason whatsoever for this to be the case, but after
> seeing so many impossible things already, it wouldn't even seem that
> surprising to me.
>
>  For the record, I'm creating my chroots using commands like this:
>
>         # debootstrap --arch amd64 sid /srv/chroot/sid-amd64 http://httpredir.debian.org/debian
>         # mount -t proc proc /srv/chroot/sid-amd64/proc
>         # mount -t devpts devpts /src/chroot/sid-amd64/dev/pts
>         # chroot /srv/chroot/sid-amd64 apt install g++-mingw-w64-i686
>
>
>  I guess I'll need to update one of my real Stretch systems to Buster and
> try redoing the test outside of chroot -- unless you're using a chroot as
> well and so this is not the source of the problem?

Well the issue is totally reproducible here.

# i686-w64-mingw32-g++ -c -std=c++17 -O2 -Wnonnull
-Woverloaded-virtual -v 16795.cpp -o warn.o
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-g++
Target: i686-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu
--prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man'
--infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var
--disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu'
--libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode
--disable-dependency-tracking --prefix=/usr --enable-shared
--enable-static --disable-multilib --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib
--enable-libstdcxx-time=yes --with-tune=generic
--with-headers=/usr/i686-w64-mingw32/include
--enable-version-specific-runtime-libs --enable-fully-dynamic-string
--enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada
--enable-lto --with-plugin-ld --enable-threads=win32
--program-suffix=-win32 --program-prefix=i686-w64-mingw32-
--target=i686-w64-mingw32 --with-as=/usr/bin/i686-w64-mingw32-as
--with-ld=/usr/bin/i686-w64-mingw32-ld --enable-libatomic
--enable-libstdcxx-filesystem-ts=yes
Thread model: win32
gcc version 7.2-win32 20180123 (GCC)
COLLECT_GCC_OPTIONS='-c' '-std=c++1z' '-O2' '-Wnonnull'
'-Woverloaded-virtual' '-v' '-o' 'warn.o' '-shared-libgcc'
'-mtune=generic' '-march=pentiumpro'
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/cc1plus -quiet -v
-U_REENTRANT 16795.cpp -quiet -dumpbase 16795.cpp -mtune=generic
-march=pentiumpro -auxbase-strip warn.o -O2 -Wnonnull
-Woverloaded-virtual -std=c++1z -version -o /tmp/ccPhl5Oq.s
GNU C++14 (GCC) version 7.2-win32 20180123 (i686-w64-mingw32)
compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version
4.0.1-rc1, MPC version 1.1.0, isl version isl-0.18-GMP

warning: MPFR header version 4.0.1-rc1 differs from library version 4.0.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/include/c++
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/include/c++/i686-w64-mingw32
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/include/c++/backward
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/include
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/include-fixed
 /usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/include
End of search list.
GNU C++14 (GCC) version 7.2-win32 20180123 (i686-w64-mingw32)
compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version
4.0.1-rc1, MPC version 1.1.0, isl version isl-0.18-GMP

warning: MPFR header version 4.0.1-rc1 differs from library version 4.0.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4c0706b346120c11493ae8cc1ecc0022
16795.cpp: In function 'unsigned int _get_output_format()':
16795.cpp:316:25: warning: 'unsigned int _get_output_format()'
redeclared without dllimport attribute: previous dllimport ignored
[-Wattributes]
 extern "C" unsigned int _get_output_format(void) {return 1;}
                         ^~~~~~~~~~~~~~~~~~
COLLECT_GCC_OPTIONS='-c' '-std=c++1z' '-O2' '-Wnonnull'
'-Woverloaded-virtual' '-v' '-o' 'warn.o' '-shared-libgcc'
'-mtune=generic' '-march=pentiumpro'
 /usr/bin/i686-w64-mingw32-as -v -o warn.o /tmp/ccPhl5Oq.s
GNU assembler version 2.29.1 (i686-w64-mingw32) using BFD version (GNU
Binutils) 2.29.1
COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-w64-mingw32/7.2-win32/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/lib/../lib/:/usr/lib/gcc/i686-w64-mingw32/7.2-win32/../../../../i686-w64-mingw32/lib/
COLLECT_GCC_OPTIONS='-c' '-std=c++1z' '-O2' '-Wnonnull'
'-Woverloaded-virtual' '-v' '-o' 'warn.o' '-shared-libgcc'
'-mtune=generic' '-march=pentiumpro'
# i686-w64-mingw32-objdump -d warn.o | grep -A 2 test_main
000001a0 <__Z9test_mainiPPc>:
 1a0: f0 83 05 4c 00 00 00 lock addl $0x1,0x4c
 1a7: 01




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux