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

--- Comment #1 from Vsevolod Livinskiy <vsevolod.livinskij at frtk dot ru> ---
(In reply to Vsevolod Livinskiy from comment #0)
> Created attachment 38314 [details]
> Reproducer.
> 
> Test case produces incorrect result.
> 
> Output:
> > clang++ repr.cpp; ./a.out
> -4
> > g++ repr.cpp; ./a.out
> 137438953468
> 
> GCC version:
> > g++ -v
> Using built-in specs.
> COLLECT_GCC=g++
> COLLECT_LTO_WRAPPER=/export/users/vlivinsk/gcc-trunk/bin/libexec/gcc/x86_64-
> pc-linux-gnu/7.0.0/lto-wrapper
> Target: x86_64-pc-linux-gnu
> Configured with: /export/users/vlivinsk/gcc-trunk/gcc/configure
> --with-arch=corei7 --with-cpu=corei7 --enable-clocale=gnu --with-system-zlib
> --enable-shared --with-demangler-in-ld --enable-cloog-backend=isl
> --with-fpmath=sse --enable-checking=release --enable-languages=c,c++,lto
> --with-gmp=/export/users/vlivinsk/gcc-trunk/gmp-6.1.0/bin
> --with-mpfr=/export/users/vlivinsk/gcc-trunk/mpfr-3.1.3/bin
> --with-mpc=/export/users/vlivinsk/gcc-trunk/mpc-1.0.3/bin
> --prefix=/export/users/vlivinsk/gcc-trunk/bin
> Thread model: posix
> gcc version 7.0.0 20160418 (experimental) (Revision=235129)
> 
> Test:
> #include <iostream>
> 
> struct A {
>     unsigned long member : 37;
> };
> 
> struct B {
>     A member;
> } b;
> 
> long a;
> 
> int main() {
>     b.member.member = 4;
>     a = -b.member.member;
>     if (a != 4)
>         abort();
> }

Typo. Should be
    if (a != -4)
        abort();

Reply via email to