This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/3711: va_arg + var size struct + typeof crash gcc 3.1
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/3711: va_arg + var size struct + typeof crash gcc 3.1
- From: Nicola Pero <nicola at brainstorm dot co dot uk>
- Date: 17 Jul 2001 15:29:39 -0000
- Reply-To: Nicola Pero <nicola at brainstorm dot co dot uk>
>Number: 3711
>Category: c
>Synopsis: va_arg + var size struct + typeof crash gcc 3.1
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Tue Jul 17 08:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Nicola Pero
>Release: 3.1 20010717
>Organization:
>Environment:
gnu
>Description:
Gcc 3.1 seems to have problems with typeof + va_arg
+ variable size structs; the code shown crashes gcc-3.1;
it works with the other gcc versions I tried,
which were gcc-3.0 and gcc-2.91.66.
>How-To-Repeat:
Compile the following code:
#include <stdarg.h>
#include <stdio.h>
/* This function really accepts a size, and then a struct.
We use variable args only to show a bug in the compiler. */
void functionWithArgs (int size, ...)
{
struct
{
char x[size];
} dummy;
va_list ap;
int i;
va_start (ap, size);
dummy = va_arg (ap, typeof(dummy));
for (i = 0; i < size; i++)
{
printf ("%c\n", (dummy.x)[i]);
}
va_end (ap);
}
int main (void)
{
struct
{
char y[5];
} test;
(test.y)[0] = '1';
(test.y)[1] = '2';
(test.y)[2] = '3';
(test.y)[3] = '4';
(test.y)[4] = '5';
functionWithArgs (5, test);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: