[Bug c/33610] New: Access to long double struct member from nested procedure crashes
peter_schorn at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 1 16:10:00 GMT 2007
Compile the following program:
#include <stdio.h>
long double d = 22092007.192016;
struct abc {
long double a, b, c;
};
void outer(void) {
struct abc x;
void inner(struct abc p) {
printf("Enter inner\n");
/* Next line causes problem: bus error, segmentation fault or
result of comparison is false */
if (x.a == d)
printf("OK\n");
else
printf("Fail\n");
}
x.a = d;
inner(x);
}
int main (int argc, const char * argv[]) {
outer();
return 0;
}
Compile
petersch% /Developer/Pascal/gpc421/bin/gcc -v -Wall -save-temps -o schorn3
schorn3.c
Using built-in specs.
Target: powerpc-apple-darwin8
Configured with: ../gcc-4.2.1/configure --enable-languages=c
--enable-threads=posix --target=powerpc-apple-darwin8
--host=powerpc-apple-darwin8 --build=powerpc-apple-darwin8
--prefix=/Developer/Pascal/gpc421n
Thread model: posix
gcc version 4.2.1
/Developer/Pascal/gpc421/bin/../libexec/gcc/powerpc-apple-darwin8/4.2.1/cc1 -E
-quiet -v -iprefix
/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1/
-D__DYNAMIC__ schorn3.c -fPIC -Wall -fpch-preprocess -o schorn3.i
ignoring nonexistent directory
"/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1/../../../../powerpc-apple-darwin8/include"
ignoring nonexistent directory "/Developer/Pascal/gpc421n/include"
ignoring nonexistent directory
"/Developer/Pascal/gpc421n/lib/gcc/powerpc-apple-darwin8/4.2.1/include"
ignoring nonexistent directory
"/Developer/Pascal/gpc421n/powerpc-apple-darwin8/include"
#include "..." search starts here:
#include <...> search starts here:
/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1/include
/usr/local/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
/Developer/Pascal/gpc421/bin/../libexec/gcc/powerpc-apple-darwin8/4.2.1/cc1
-fpreprocessed schorn3.i -fPIC -quiet -dumpbase schorn3.c -auxbase schorn3
-Wall -version -o schorn3.s
GNU C version 4.2.1 (powerpc-apple-darwin8)
compiled by GNU C version 4.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 08ab063eb304b807ad0f3113ee916e74
as -arch ppc -o schorn3.o schorn3.s
/Developer/Pascal/gpc421/bin/../libexec/gcc/powerpc-apple-darwin8/4.2.1/collect2
-dynamic -arch ppc -weak_reference_mismatches non-weak -o schorn3 -lcrt1.o
/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1/crt2.o
-L/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1
-L/Developer/Pascal/gpc421/bin/../lib/gcc
-L/Developer/Pascal/gpc421/bin/../lib/gcc/powerpc-apple-darwin8/4.2.1/../../..
schorn3.o -lgcc -lSystemStubs -lSystem
Running it will create a "Bus error" or might print "Fail" or terminate with a
segmentation fault depending on the nature of the wrong address of x.a. The
problem disappears when compiling with -fpack-struct=4.
petersch% ./schorn3
Enter inner
Bus error
[petersch%
--
Summary: Access to long double struct member from nested
procedure crashes
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: peter_schorn at yahoo dot com
GCC build triplet: powerpc-apple-darwin8
GCC host triplet: powerpc-apple-darwin8
GCC target triplet: powerpc-apple-darwin8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33610
More information about the Gcc-bugs
mailing list