From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicola Pero To: gcc-gnats@gcc.gnu.org Subject: c/3711: va_arg + var size struct + typeof crash gcc 3.1 Date: Tue, 17 Jul 2001 08:36:00 -0000 Message-id: <20010717152939.3173.qmail@sourceware.cygnus.com> X-SW-Source: 2001-07/msg00450.html List-Id: >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 #include /* 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: