This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug (?) in gcc version 2.95.2 19991024 (release-2)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: bug (?) in gcc version 2.95.2 19991024 (release-2)
- From: Trevor Jim <trevor at research dot att dot com>
- Date: 01 Sep 2000 15:51:24 -0400
Hello. I think I've found a bug in gcc, possibly involving statement
expressions. Gcc compiles a program so that it does not produce the
expected output. If the bug can be avoided with a command-line flag
(turning off something) I'd like to know. The code is machine
generated, so it is not easy for me to fix each time. (I've
simplified the example as much as I could.)
Thanks for your efforts!
Trevor
Details:
gcc version 2.95.2 19991024 (release-2)
I'm running Windows 2000 Professional and I got gcc via the Cygwin
binary package. I compiled the code with no options. The program is
stand-alone, it requires no input files.
The code should print
EXPECTING 9999,9999
GOT 9999,9999
but instead, it prints
EXPECTING 9999,9999
GOT 4444,-222
------------------------cut here---------------------------------
#include <stdio.h>
struct A {
int key;
int data;
void *left;
};
struct B {
struct A *v;
};
struct A yy = { -222, 4444, NULL };
int main() {
struct A *y = &yy;
struct A *z = (struct A *)malloc(sizeof(struct A));
printf("EXPECTING 9999,9999\n");
*z =
(struct A) {
9999,
9999,
(void *) ({
struct B *t2 = (struct B *)malloc(sizeof(struct B));
*t2 =
(struct B) {
({
struct A *t3 = (struct A *)malloc(sizeof(struct A));
*t3 = (struct A){y->key, y->data, NULL};
t3;
})
};
t2;
})
};
printf(" GOT %d,%d\n",z->data,z->key);
return 0;
}