From mboxrd@z Thu Jan 1 00:00:00 1970 From: voel@diku.dk To: gcc-gnats@gcc.gnu.org Subject: c/2243: Misplacement of label at start of function. Date: Sun, 01 Apr 2001 00:00:00 -0000 Message-id: <20010309154642.6406.qmail@sourceware.cygnus.com> X-SW-Source: 2001-q1/msg02146.html List-Id: >Number: 2243 >Category: c >Synopsis: Misplacement of label at start of function. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Mar 09 07:56:03 PST 2001 >Closed-Date: >Last-Modified: >Originator: Rasmus Erik Voel Jensen >Release: gcc version 2.95.2 19991024 (release) (andalso CodeSourcery's Online Test Compilation) >Organization: >Environment: Linux 2.2.16-3, i686 >Description: Labels in the start of a function is placed at the function entry instead of inside the function if the following conditions hold: * the source is compiled on the i386-platform. * optimization is enabled (not run with -O0). * there is no goto's to the label. >How-To-Repeat: Compile the following code with ``gcc -O1 labelerr.c''. If you then look at the objectcode it is clear that the prelude- size > 0 (ebp is pushed on the stack, and the stackpointer is saved). labelerr.c: /* * The label should be after the prelude, such that a jump * to it would not inflect a new stackframe. * It is misplaced if the code is optimized end there is no * goto to the label. It is only observed on the ia-32 arch. */ int main(argv, argc) char **argv; int argc; { label: printf("Preludesize = %x\n", &&label-((void *)main)); return 1; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: