Bug 28202 - ARM cross-compiler seg. fault with -mfpu=vfp and optimization
Summary: ARM cross-compiler seg. fault with -mfpu=vfp and optimization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: 4.1.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-06-29 16:03 UTC by clifford.slocombe
Modified: 2006-06-30 12:31 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description clifford.slocombe 2006-06-29 16:03:29 UTC
Version info:
------------------
E:\vfpfault>arm-elf-gcc -v
Using built-in specs.
Target: arm-elf
Configured with: ../../gcc-4.0.2/configure --enable-languages=c,c++ --enable-interwork --enable-multilib --with-gcc --with-gnu-ld --with-gnu-as --with-stabs --disable-shared --disable-threads --disable-win32-registry --disable-nls --target=arm-elf --with-newlib --prefix=c:/WinARM -v
Thread model: single
gcc version 4.0.2 (WinARM)
------------------

Compile log:
------------------
E:\vfpfault>arm-elf-gcc -c -O2 -mfpu=vfp -mfloat-abi=softfp test.c
test.c: In function 'test':
test.c:4: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
------------------

Code to reproduce error (test.c)
------------------
double test( double x )           // Line 1
{                                 // Line 2
  return (x >= 0 ? 0 : -1.0);     // Line 3
}                                 // Line 4 - error reproted here.

-EOF--------------

I originally encountered this bug in code written to evaluate the performance of the Philips LPC3180 microcontroller (which has VFP hardware) and GCC. The error went away when I modified the code. I then encountered it again when attempting to rebuild Newlib-1.14.0 for VFP support, where it occurred in mathfp/s_floor.c. The code presented here is derived from the newlib code by cutting it down to the smallest code possible that reproduces the error and with no dependencies.

The error occurs also when line 3 is replaced with the following:

return( x >= 0 ) ;
return( x <= 0 ) ;
return( x > 0 ) ;
return( x < 0 ) ;

Although in all four of the above, if the return type is changed to int, it does not fail.

In all cases if -mfpu=vfp or the -Ox option is removed, the error does not occur.

The error occurs for all of -Os, -O1, -O2, -O3, (but not -O0).

The test platform details for the test were:
Windows XP Pro SP2
HP Compaq nx8220 Laptop, Pentium M 2.0GHz, 1Gb RAM

Note that the compiler used was a native Win32 build and not a Cygwin dependant or Linux hosted build.
Comment 1 clifford.slocombe 2006-06-29 16:06:53 UTC
The line "The error occurs also when line 3 is replaced with the following:" should read "The error occurs also when line 3 is replaced with either of the following:"

Clifford
Comment 2 Andrew Pinski 2006-06-29 19:08:26 UTC
This works on the mainline.
Comment 3 clifford.slocombe 2006-06-30 12:28:42 UTC
I have now retested on 4.1.1 and seems good also. Thanks.

Details for reference:

$gcc -v
Using built-in specs.
Target: arm-elf
Configured with: ../../gcc-4.1.1/configure --enable-languages=c,c++ --enable-interwork --enable-multilib --with-gcc --with-gnu-ld --with-gnu-as --with-stabs --disable-shared --disable-threads --disable-libssp --disable-libstdcxx-pch --disable-libmudflap --disable-win32-registry --disable-nls --disable-debug --without-headers --with-newlib --target=arm-elf --prefix=c:/WinARM -v
Thread model: single
gcc version 4.1.1 (WinARM)

Comment 4 Andrew Pinski 2006-06-30 12:31:22 UTC
Fixed in 4.1.1 so closing as fixed.