osdir.com
mailing list archive

Subject: c/7574: Code generation problem involving regparm attribute - msg#00223

List: gcc.prs

Date: Prev Next Index Thread: Prev Next Index

>Number: 7574
>Category: c
>Synopsis: Code generation problem involving regparm attribute
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sun Aug 11 17:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Eric R. Krause
>Release: gcc 3.2 20020809 (prerelease)
>Organization:
>Environment:
Cygwin 1.3.12, Windows 2000 Professional SP2 (5.0.2195)
AMD Athlon Processor
>Description:
gcc configuration:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /usr/src/gcc-3.2-20020809/configure --with-gcc --with-gnu-as
--with-gnu-ld --enable-shared --program-suffix=-3.2 --enable-threads=win32
--disable-win32-registry --disable-nls --enable-languages=c,c++
--enable-version-specific-runtime-libs
Thread model: win32
gcc version 3.2 20020809 (prerelease)

Details:
gcc 3.2 produces incorrect code for situations where a function defined with
the regparm (1) attribute is called via a pointer, but only if that pointer is
stored in an array AND the array subscript is used as the pointer.

What I mean by using the array subscript as a pointer, is that the function
would be called with an expression like:
fnPtrArray[x](...);

Note that retrieving the pointer from the array, assigning it to a function
pointer variable, and then dispatching the call using the pointer variable DOES
work as expected with gcc 3.2:
fnPtr = fnPtrArray[x];
fnPtr(...);

Bug:
gcc 3.2 seems not to recognize that the function being called has the regparm
attribute: as a matter of fact, it PUSHES the intended argument value on the
stack, loads the pointer into %eax (where the argument value SHOULD be) and
then does a 'call *%eax'.

gcc 2.95.x would use a different register to set up the call-through-pointer;
%eax contained the correct argument value.

I suspect this problem is also present in gcc 3.1 and gcc 3.1.1.
>How-To-Repeat:
In the attached tarball, there are two files: x86codebug.c and x86codebug.i.
The latter is the pre-processed output generated under Cygwin.

Compile x86codebug.c _with gcc 3.2_ and run it. The first line of output
should read "Should be 100: 100", but it won't when you run it.
>Fix:
Workaround: Assign the pointer array element to a temporary, then dispatch the
call using the temporary.
>Release-Note:
>Audit-Trail:
>Unformatted:



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

optimization/7571: BitchX fails with a segmentation fault when compiled with -O3

>Number: 7571 >Category: optimization >Synopsis: BitchX fails with a segmentation fault when compiled with -O3 >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Aug 11 09:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Tony Clark >Release: pre_3.2 >Organization: >Environment: Gentoo Linux 1.4 beta system. Kernel 2.4.19 standard. glibc2.2.5. Dual Athlon on AMD MPX chipset. >Description: BitchX failts to run an reports a segemntation fault when compiled with the optimisation set to -march=athlon-mp -O3 -pipe -Wall -Wunused. Program runs ok when compiled with -O2. >How-To-Repeat: Compile as per the description. >Fix: >Release-Note: >Audit-Trail: >Unformatted:

Next Message by Date: click to view message preview

other/7575: gcc crashes when trying to compile static constants stored in .cpp files

>Number: 7575 >Category: other >Synopsis: gcc crashes when trying to compile static constants stored in >.cpp files >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Aug 11 18:36:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Alex Bacon >Release: 3.0.2 >Organization: >Environment: HPUX (heaven help me) >Description: /usr/local/include/g++-v3/bits/stl_alloc.h: In function `void __static_initialization_and_destruction_0(int, int)': /usr/local/include/g++-v3/bits/stl_alloc.h:79: Internal compiler error in emit_move_insn_1, at expr.c:3003 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. make: *** [ProcessNewCustomers.o] Error 1 >How-To-Repeat: Compile using single threaded gcc compiler on HPUX. (It seems to work with posix threaded compiler on Sun) >Fix: Put consts into header file >Release-Note: >Audit-Trail: >Unformatted:

Previous Message by Thread: click to view message preview

optimization/7571: BitchX fails with a segmentation fault when compiled with -O3

>Number: 7571 >Category: optimization >Synopsis: BitchX fails with a segmentation fault when compiled with -O3 >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Aug 11 09:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Tony Clark >Release: pre_3.2 >Organization: >Environment: Gentoo Linux 1.4 beta system. Kernel 2.4.19 standard. glibc2.2.5. Dual Athlon on AMD MPX chipset. >Description: BitchX failts to run an reports a segemntation fault when compiled with the optimisation set to -march=athlon-mp -O3 -pipe -Wall -Wunused. Program runs ok when compiled with -O2. >How-To-Repeat: Compile as per the description. >Fix: >Release-Note: >Audit-Trail: >Unformatted:

Next Message by Thread: click to view message preview

other/7575: gcc crashes when trying to compile static constants stored in .cpp files

>Number: 7575 >Category: other >Synopsis: gcc crashes when trying to compile static constants stored in >.cpp files >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Aug 11 18:36:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Alex Bacon >Release: 3.0.2 >Organization: >Environment: HPUX (heaven help me) >Description: /usr/local/include/g++-v3/bits/stl_alloc.h: In function `void __static_initialization_and_destruction_0(int, int)': /usr/local/include/g++-v3/bits/stl_alloc.h:79: Internal compiler error in emit_move_insn_1, at expr.c:3003 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. make: *** [ProcessNewCustomers.o] Error 1 >How-To-Repeat: Compile using single threaded gcc compiler on HPUX. (It seems to work with posix threaded compiler on Sun) >Fix: Put consts into header file >Release-Note: >Audit-Trail: >Unformatted:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by