[Bug c/64918] invalid (?) warning when initializing structure
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918 --- Comment #2 from Øystein Schønning-Johansen --- Really insightful, Joseph. I do understand the warning a bit better now. I have not looked into the GCC parsing code, but based on your description and my (limited) understanding of the problem, I guess a fix is not trivial? Can I suppress this warning in any way? -Ø
[Bug c/64918] New: invalid (?) warning when initializing structure
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918 Bug ID: 64918 Summary: invalid (?) warning when initializing structure Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: oystein at gnubg dot org Created attachment 34651 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34651&action=edit Code that trigger the invalid warning. Hi! I'm initializing a complex structure with designated initialisers and overriding an array element (intentionally), and I then get the error message: sideffects.c:26:13: warning: initialized field with side-effects overwritten [3] = { .func = thefunction, .args = &((char*[]){"foo4", "bar4", "baz4"})}, ^ sideffects.c:26:13: warning: (near initialization for 'myconfig.config[3]') However I do believe my code is correct. It complains about initializing with side-effects, but I think my code is legal c99. (Please tell me otherwise.) I compile the attached code with: gcc -std=gnu99 -Wall -Wextra -Wno-override-init sideeffects.c -o sideeffects I have tried several different versions of GCC, and here is a short summary: GCC 4.9.2 (Arch Linux x86_64) -> Warning generated. GCC 4.9.2 (Mingw32-w64 x86_64) -> Warning generated. GCC 4.8.0 (Linux x86_64) -> Warning generated. GCC 4.4.7 (Red Hat 4.4.7-4)-> No warning. GCC 4.1.2 (Red Hat 4.1.2-52) -> No warning. clang 3.5.1 (Arch Linux) -> No warning. Best regards, -Øystein Full info on compilers used (Those that generates warning): [oystein@jupiter ~]$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc/src/gcc-4.9-20141224/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.9.2 20141224 (prerelease) (GCC) [14:29:03,90 c:\APPL]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-4.9.2-posix-seh-rt_v3-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.9.2/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-posix-seh-rev1, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/include -I/c/mingw492/prerequisites/x86_64-zlib-static/include -I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/include -I/c/mingw492/prerequisites/x86_64-zlib-static/include -I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/lib -L/c/mingw492/prerequisites/x86_64-zlib-static/lib -L/c/mingw492/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 4.9.2 (x86_64-posix-seh-rev1, Built by
[Bug c/59697] Function attribute __target_(("no-avx)) work on Windows/mingw but fails on Linux.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59697 --- Comment #1 from Øystein Schønning-Johansen --- Follow up: I try the same code on a RedHat 6.5 64bit workstation with GCC4.4. st-lx794988(ojohans) -/ojohans 37> gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) On this system the sse function is also translated to avx instructions. :-( 004004f0 : 4004f0:c1 fe 02 sar$0x2,%esi 4004f3:85 f6test %esi,%esi 4004f5:74 2eje 400525 4004f7:83 ee 01 sub$0x1,%esi 4004fa:c5 f8 c6 c0 00 vshufps $0x0,%xmm0,%xmm0,%xmm0 4004ff:48 c1 e6 04 shl$0x4,%rsi 400503:48 8d 44 37 10 lea0x10(%rdi,%rsi,1),%rax 400508:0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) 40050f:00 400510:c5 f8 28 0f vmovaps (%rdi),%xmm1 400514:c5 f0 59 c8 vmulps %xmm0,%xmm1,%xmm1 400518:c5 f8 29 0f vmovaps %xmm1,(%rdi) 40051c:48 83 c7 10 add$0x10,%rdi 400520:48 39 c7 cmp%rax,%rdi 400523:75 ebjne400510 400525:f3 c3repz retq 400527:66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) -Øystein
[Bug c/59697] New: Function attribute __target_(("no-avx)) work on Windows/mingw but fails on Linux.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59697 Bug ID: 59697 Summary: Function attribute __target_(("no-avx)) work on Windows/mingw but fails on Linux. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: oystein at gnubg dot org Created attachment 31754 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31754&action=edit Example source code file Hi, As I last week tried to compile a file with one function to sse instruction and another to avx, (see invalid bug report #59657), I tried to solve this by using function attributes. static void calculate_sse(float *data, float scale, int size ) __attribute__ ((__target__ ("no-avx"))); static void calculate_avx(float *data, float scale, int size ); (Full example code attached) When I compile this as my mingw system, the produced code is as expected, and the code runs good at my no-avx Windows-machine. Compiled with: gcc -Wall -O3 -g -mavx sse_test.c -o sse_test [10:52:28,97 C:\APPL\ssetest]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/appl/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --wit h-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-wi th-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.7.2 (GCC) Disassembly of the calculate_sse functions looks like this: (gdb) disassemble calculate_sse Dump of assembler code for function calculate_sse: 0x0040138c <+0>: mov0xc(%esp),%eax 0x00401390 <+4>: sar$0x2,%eax 0x00401393 <+7>: lea-0x1(%eax),%edx 0x00401396 <+10>:test %eax,%eax 0x00401398 <+12>:je 0x4013be 0x0040139a <+14>:mov0x4(%esp),%eax 0x0040139e <+18>:movss 0x8(%esp),%xmm0 0x004013a4 <+24>:shufps $0x0,%xmm0,%xmm0 0x004013a8 <+28>:movaps %xmm0,%xmm1 0x004013ab <+31>:nop 0x004013ac <+32>:movaps (%eax),%xmm0 0x004013af <+35>:mulps %xmm1,%xmm0 0x004013b2 <+38>:movaps %xmm0,(%eax) 0x004013b5 <+41>:add$0x10,%eax 0x004013b8 <+44>:dec%edx 0x004013b9 <+45>:cmp$0x,%edx 0x004013bc <+48>:jne0x4013ac 0x004013be <+50>:ret End of assembler dump. All nice and as expected on Windows/mingw! I then try the same code with the same function attribute on my Arch linux laptop (also non-avx CPU). But on this system the calculate_sse functions is compiled with avx instruction despite the function attribute. I compile with the same command line: gcc -Wall -O3 -g -mavx sse_test.c -o sse_test [oystein@oysteins-laptop ~]$ gcc --version gcc (GCC) 4.8.2 20131219 (prerelease) Produced disassembly of calculate_sse function: (gdb) disassemble Dump of assembler code for function calculate_sse: 0x08048440 <+0>:mov0xc(%esp),%ecx 0x08048444 <+4>:mov0x4(%esp),%eax 0x08048448 <+8>:sar$0x2,%ecx 0x0804844b <+11>:test %ecx,%ecx 0x0804844d <+13>:lea-0x1(%ecx),%edx 0x08048450 <+16>:je 0x8048474 => 0x08048452 <+18>:vbroadcastss 0x8(%esp),%xmm1 0x08048459 <+25>:lea0x0(%esi,%eiz,1),%esi 0x08048460 <+32>:vmulps (%eax),%xmm1,%xmm0 0x08048464 <+36>:sub$0x1,%edx 0x08048467 <+39>:add$0x10,%eax 0x0804846a <+42>:vmovaps %xmm0,-0x10(%eax) 0x0804846f <+47>:cmp$0x,%edx 0x08048472 <+50>:jne0x8048460 0x08048474 <+52>:repz ret End of assembler dump. I'm always unsure what to expect, but at least I did not the behavior to be different on the two systems. Well, it might not be the Windows/Linux systems that makes the difference but maybe rather the 4.7.x / 4.8.x gcc-version that makes the difference. What do I know? Thanks, -Øystein
[Bug c/59657] New: SSE intrinsics translates to AVX instructions
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59657 Bug ID: 59657 Summary: SSE intrinsics translates to AVX instructions Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: oystein at gnubg dot org Created attachment 31558 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31558&action=edit Example source code file Happy new year! I writing code which should be running both on sse and avx machines. I have manually vectorized the code for SSE and AVX in two different functions and using a function pointer to set the right function according to CPU at startup. The two functions are in the same translation unit. (See attached code) compiled with: gcc -Wall -O3 -g -mavx sse_test.c -o sse_test The problem is that the sse intisics in the sse function gets translated to AVX instructions. This will of course give an illegal instruction on on all non-AVX machines. My gdb session: Program received signal SIGILL, Illegal instruction. 0x08048452 in calculate_sse (data=data@entry=0xb5e0, scale=scale@entry=0.5, size=size@entry=256) at sse_test.c:33 33for ( ; count-- ; p += 4 ){ (gdb) list 28 29static void calculate_sse(float *data, float scale, int size ) 30{ 31int count = size >> 2; 32float *p = data; 33for ( ; count-- ; p += 4 ){ 34__m128 d = _mm_load_ps( p ); 35__m128 s = _mm_set1_ps( scale ); 36_mm_store_ps( p, _mm_mul_ps( d, s )); 37} (gdb) disassemble Dump of assembler code for function calculate_sse: 0x08048440 <+0>:mov0xc(%esp),%ecx 0x08048444 <+4>:mov0x4(%esp),%eax 0x08048448 <+8>:sar$0x2,%ecx 0x0804844b <+11>:test %ecx,%ecx 0x0804844d <+13>:lea-0x1(%ecx),%edx 0x08048450 <+16>:je 0x8048474 => 0x08048452 <+18>:vbroadcastss 0x8(%esp),%xmm1 0x08048459 <+25>:lea0x0(%esi,%eiz,1),%esi 0x08048460 <+32>:vmulps (%eax),%xmm1,%xmm0 0x08048464 <+36>:sub$0x1,%edx 0x08048467 <+39>:add$0x10,%eax 0x0804846a <+42>:vmovaps %xmm0,-0x10(%eax) 0x0804846f <+47>:cmp$0x,%edx 0x08048472 <+50>:jne0x8048460 0x08048474 <+52>:repz ret End of assembler dump. (Arch linux) [oystein@oysteins-laptop ~]$ gcc --version gcc (GCC) 4.8.2 20131219 (prerelease) Bug or feature? I'm not sure if this is the expected way the intrisics should translate, but it was not what I expected. If it is supposed to be like this, can I get out of my problem without splitting the the two functions to two translation units and use two different compile options? Thanks, Øystein
[Bug c/39194] New: options -O3 and -msse does not cooperate ?
Hi, I try the following code: #define MAX_N 40 #define MAX_R 25 #ifndef FALSE #define FALSE 0 #define TRUE 1 #endif static unsigned int bin_coeff_tab[ MAX_N ][ MAX_R ]; static int is_calculated = FALSE; static void bin_coeff_init( void ) { int i, j; for( i = 0; i < MAX_N; i++ ) bin_coeff_tab[ i ][ 0 ] = i + 1; for( j = 1; j < MAX_R; j++ ) bin_coeff_tab[ 0 ][ j ] = 0; for( i = 1; i < MAX_N; i++ ) for( j = 1; j < MAX_R; j++ ) bin_coeff_tab[ i ][ j ] = bin_coeff_tab[ i - 1 ][ j - 1 ] + bin_coeff_tab[ i - 1 ][ j ]; is_calculated = TRUE; } int main() { bin_coeff_init(); return 0; } (There is no header file included, so I won't include the .i file) If I try to compile this with both -O3 and -msse, I get a segmentation fault. > gcc --version gcc (GCC) 4.3.0 20080305 (alpha-testing) mingw-20080502 the assembler code file becomes: .file "mytest.c" .def___main;.scl2; .type 32; .endef .text .p2align 2,,3 .globl _main .def_main; .scl2; .type 32; .endef _main: leal4(%esp), %ecx andl$-16, %esp pushl -4(%ecx) pushl %ebp movl%esp, %ebp pushl %esi pushl %ebx pushl %ecx subl$12, %esp call___main movl$_bin_coeff_tab, %edx xorl%eax, %eax .p2align 2,,3 L2: incl%eax movl%eax, (%edx) addl$100, %edx cmpl$40, %eax jne L2 movl$0, _bin_coeff_tab+4 movl$0, _bin_coeff_tab+8 movl$0, _bin_coeff_tab+12 xorps %xmm0, %xmm0 movaps %xmm0, _bin_coeff_tab+16 movaps %xmm0, _bin_coeff_tab+32 movaps %xmm0, _bin_coeff_tab+48 movaps %xmm0, _bin_coeff_tab+64 movaps %xmm0, _bin_coeff_tab+80 movl$0, _bin_coeff_tab+96 movl$1, %esi .p2align 2,,3 L3: leal(%esi,%esi,4), %eax leal(%eax,%eax,4), %eax leal_bin_coeff_tab-100(,%eax,4), %edx leal_bin_coeff_tab+4(,%eax,4), %ebx movl$1, %ecx .p2align 2,,3 L4: movl4(%edx), %eax addl(%edx), %eax movl%eax, (%ebx) incl%ecx addl$4, %edx addl$4, %ebx cmpl$25, %ecx jne L4 incl%esi cmpl$40, %esi jne L3 movl$1, _is_calculated xorl%eax, %eax addl$12, %esp popl%ecx popl%ebx popl%esi leave leal-4(%ecx), %esp ret .lcomm _is_calculated,16 .lcomm _bin_coeff_tab,4000 Best regards, -Øystein -- Summary: options -O3 and -msse does not cooperate ? Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oystein at gnubg dot org GCC host triplet: windows (mingw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39194
[Bug target/21126] internal compiler error: in output_constant_pool_2, at varasm.c:3232
--- Additional Comments From oystein at gnubg dot org 2005-04-24 23:06 --- I've fetched the cvs sources today, and the code builds today. I don't know what's different, but it's not the source file that's changed. The snapshit tarball build fails in the same way as usual. Using built-in specs. Target: mingw32 Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/gcc4.0 --enable-threads --disable-nls --enable-languages=c,c++ --disable-win32-registry --disable-shared Thread model: win32 gcc version 4.1.0 20050424 (experimental) I'm closing this bug! OK? -- What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||WORKSFORME http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21126
[Bug target/21126] internal compiler error: in output_constant_pool_2, at varasm.c:3232
--- Additional Comments From oystein at gnubg dot org 2005-04-20 20:31 --- H I'm a bit skeptic to the compiler installation. I did a configure with --prefix=/home/mingw/. Then I did a 'make install'. I notice now that /home/mingw/include/ is empty. Should it be? (And which header files was then used in the compilation?) -Øystein -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21126
[Bug c/21126] New: internal compiler error: in output_constant_pool_2, at varasm.c:3232
gcc -v Using built-in specs. Target: mingw32 Configured with: ../gcc-4.1-20050410/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/home/mingw --enable-threads --disable-nls --enable-languages=c,c++,treelang --disable-win32-registry --disable-shared Thread model: win32 gcc version 4.1.0 20050410 (experimental) /msys/1.0/home/mingw/bin/gcc.exe -g -Wall -O3 -msse -mtune=pentium3 -DHAVE_CONFI G_H -I. -I.. -c -o neuralnet.o neuralnet.c neuralnet.c: In function 'Evaluate': neuralnet.c:540: internal compiler error: in output_constant_pool_2, at varasm.c :3232 Please submit a full bug report, with preprocessed source if appropriate. See http://gcc.gnu.org/bugs.html> for instructions. make: *** [neuralnet.o] Error 1 Preprocessed files can be found here: http://home.online.no/~oeysteij/neuralnet.i http://home.online.no/~oeysteij/neuralnet.s -- Summary: internal compiler error: in output_constant_pool_2, at varasm.c:3232 Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oystein at gnubg dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: 4.1.0 20050410 (built with msys 1.0.10) GCC host triplet: i686-mingw GCC target triplet: i686-mingw http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21126