gcc 4.3.2 compiler included with kubuntu fails on simple structure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-defaults (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I have simple test case of a program which manifests a problem I have in a much larger program.
The problem is something to do with structure member access when one of he members is 64 bits long. I've (tried to) include three files which easily reproduce the problem: main.c testrio.c and testrio.h
I got kubuntu from a CD in "The official Ubuntu Book". I don't know which version it is. I subsequently installed the the gcc compiler via the GUI. Things seemed to work well. In fact I tested it on several simple programs. When I started to build my main project - I had problems which I have distilled to this simple test. You can only imagine the amount of time it takes to isolate this. gcc -v produces
ramey@Robert-
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-
--with-
,fortran,
dir=/usr/lib --without-
th-gxx-
nu --enable-
--enable-
i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
The attachment system here only lets me include one file. I've concatonated the three files here instead:
/******** testrio.h **********/
#ifndef __TESTRIO__
#define __TESTRIO__
#define _FILE_OFFSET_BITS 64
#include <sys/types.h> /* off_t */
typedef struct {
off_t fs;
unsigned int i1;
unsigned int i2;
} TESTRIO;
extern int
rio_init(TESTRIO *rio);
#endif /* __TESTRIO__ */
/********* testrio.c ***********/
#include "testrio.h"
extern int
rio_init(TESTRIO *rio){
rio->fs = (off_t)(-1);
rio->i1 = 1;
rio->i2 = 2;
return 0;
}
/********* main.c ************/
#include <stdio.h> /* printf */
#include "testrio.h"
int
main(
int argc,
char *argv[]
){
TESTRIO rio;
rio_init(&rio);
printf("i1=%u, i2=%u\n", rio.i1, rio.i2);
return 0;
}
I use the following command line to build this test:
gcc -ggdb -o testrio main.c testrio.c
I run the test with:
ramey@Robert-
i1=4294967295, i2=1
Bus error
As you can see, the output is not what one would expect from looking at testrio.c
Please suggest to me what I should do.
Thank you.
Robert Ramey
PS. I've compiled the same programs on my cygwin gcc 4.32 compiler with no surprises or problems. It is for this reason I suspect the gcc version distributed with ubuntu.
RR
Changed in gcc-defaults (Ubuntu): | |
status: | New → Invalid |
In looking for a solution to this problem, I discovered that gcc-4.2 is also installed on my system.
ramey@Robert- Desktop: ~/psort/ nix/linux/ testrio$ gcc-4.2 -v languages= c,c++,fortran, objc,obj- /usr/lib --wit gettext --enable- threads= posix --enable-nls --with- gxx-include- dir c++/4.2 --program- suffix= -4.2 --enable- clocale= gnu --enable-libstd targets= all --enable-checking= i486-linux- gnu --host= i486-linux- gnu --target= i486-linux- gnu
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-
++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=
out-included-
/usr/include/
xx-debug --enable-objc-gc --enable-mpfr --enable-
elease --build=
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-3ubuntu4)
I get the same results here.