[Bug c/33374] New: GCC 4.1.2 produce wrong assembler code with -O2 option enabled.
I use gcc 4.1.2 under solaris and linux and compile code using next commands: Linux: gcc -pipe -Wall -Wextra -Winvalid-pch -ansi -pedantic -Wundef -Wc++-compat -Wfloat-equal -Wredundant-decls -Waggregate-return -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wcast-align -Wshadow -Wsign-compare -Wnested-externs -Wcast-qual -Wpointer-arith -Wdeclaration-after-statement -Werror -O2 -finline-functions -Wdisabled-optimization -DNDEBUG test.c -o mtest_l Solaris: gcc -pipe -Wall -Wextra -Winvalid-pch -ansi -pedantic -Wundef -Wc++-compat -Wfloat-equal -Wredundant-decls -Waggregate-return -Wbad-function-cast -Wstrict-prototypes -Wcast-align -Wshadow -Wsign-compare -Wnested-externs -Wcast-qual -Wpointer-arith -Wdeclaration-after-statement -Werror -O2 -finline-functions -Wdisabled-optimization -DNDEBUG -g -o mtest test.c Segmentation fault happens when I try to run test program (see test.c attached). -- Summary: GCC 4.1.2 produce wrong assembler code with -O2 option enabled. Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: _kirpichev_ at mail dot ru http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33374
[Bug c/33374] GCC 4.1.2 produce wrong assembler code with -O2 option enabled.
--- Comment #1 from _kirpichev_ at mail dot ru 2007-09-10 07:45 --- Created an attachment (id=14182) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14182&action=view) test programm This example is compiled incorrectly by gcc 4.1.2 with -O2 flag. But all works fine if we change line 93 in this example on next: XML_Remove(currNode_sp); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33374
[Bug c/33374] GCC 4.1.2 produce wrong assembler code with -O2 option enabled.
--- Comment #2 from _kirpichev_ at mail dot ru 2007-09-10 07:53 --- Created an attachment (id=14183) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14183&action=view) Correct and incorrect assembler dumps. >From incorrect dump we can see where segmentation fault heppens: 0x0804839e : movDWORD PTR [ecx+4],0x0 0x080483a5 : movDWORD PTR [eax+4],edx 0x080483a8 : movedx,DWORD PTR [ecx+4] 0x080483ab : movecx,ebx 0x080483ad : movDWORD PTR [edx],eax Instruction 0x080483ad tries to dereferencing pointer in edx, but in edx zero was put by 0x080483a8. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33374
[Bug target/33374] GCC 4.1.2 produce wrong assembler code with -O2 option enabled.
--- Comment #4 from _kirpichev_ at mail dot ru 2007-09-10 08:53 --- There is no core dump with -fno-strict-aliasing. But, our code is used by others who can not set this option. Should code compiled without -fno-strict-aliasing produce core dump? In my opinion, the best way is produce only compiliation warnings in this case. Should we rewrite our code if it is not possible to set -fno-strict-aliasing option, or it is gcc issue that fixed in other versions? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33374
[Bug c/46477] New: GCC doesn't understand %c in asm instruction with -mcmodel=large
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46477 Summary: GCC doesn't understand %c in asm instruction with -mcmodel=large Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: _kirpich...@mail.ru Hi, I'm trying to compile the following code snippet: #ifdef CONFIG_X86_32 # define __BUG_C0 "2:\t.long 1b, %c0\n" #else # define __BUG_C0 "2:\t.long 1b - 2b, %c0 - 2b\n" #endif #define BUG() \ do {\ asm volatile("1:\tud2\n"\ ".pushsection __bug_table,\"a\"\n" \ __BUG_C0 \ "\t.word %c1, 0\n" \ "\t.org 2b+%c2\n" \ ".popsection" \ : : "i" (__FILE__), "i" (__LINE__),\ "i" (10*sizeof(int))); \ } while (0) int main() { BUG(); } And everything is ok until -mcmodel=large is used. When I'm trying to use -mcmodel=large the following error appears: main.c:24:9: error: invalid 'asm': operand is neither a constant nor a condition code, invalid operand code 'c' gcc -dumpversion 4.5 BTW, if I change %c on %P then everything is ok and generated code looks the same, but I didn't find any documentation about %P.