c++/845: postfix operators don't work with va_arg() calls

fuchsia.groan@virgin.net fuchsia.groan@virgin.net
Sun Nov 19 05:56:00 GMT 2000


>Number:         845
>Category:       c++
>Synopsis:       postfix operators don't work with va_arg() calls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 19 05:56:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     peter miller
>Release:        gcc version 2.97 20001118 (experimental) (also gcc 2.96 in RedHat 7.0)
>Organization:
>Environment:
linux via codesoucery:
http://www.codesourcery.com/gcc-compile.shtml
>Description:
The code in the 'How-To-Repeat' field fails with

/tmp/@15227.7.cc: In function `void func(void*)':
/tmp/@15227.7.cc:6: cannot convert `char**' to `char*' in initialization
/tmp/@15227.7.cc:6: parse error before '[' token
/tmp/@15227.7.cc:7: cannot convert `X*' to `int' in initialization
/tmp/@15227.7.cc:7: parse error before '->' token
>How-To-Repeat:
#include <stdarg.h>

struct X { int y; };

void func(va_list va) {
   char* a = va_arg(va, char**)[0];
   int b =  va_arg(va, X*)->y; 
}
>Fix:
To workaround, parenthesize the va_arg() call before
applying the postfix operator.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list