This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/20951] New: bogus error passing &va_list to va_list*
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Apr 2005 16:51:49 -0000
- Subject: [Bug c/20951] New: bogus error passing &va_list to va_list*
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The program below fails to compile with gcc on EM64T. I believe the program is
well-formed based on 7.15.1.1 of C99, Footnote 212 (I am aware that footnotes
are not normative).
The second program below uses va_copy to get around the compilation error in the
first case fails to compile with the -ansi option (I am aware of gcc-specific
__builtin_va_copy). Even if the program did compile the solution seems
unreasonably complicated.
Can you confirm whether you agree that this is a conformance bug or not and if
not explain why not?
$ cat t.cpp && g++ --version && g++ -c t.cpp
#include <stdarg.h>
void foo (int, va_list*);
void bar (int i, va_list va)
{
foo (i, &va);
}
g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-47)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
t.cpp: In function `void bar(int, __va_list_tag*)':
t.cpp:7: cannot convert `__va_list_tag**' to `__va_list_tag (*)[1]' for
argument `2' to `void foo(int, __va_list_tag (*)[1])'
$ cat t.cpp && g++ --version && g++ -ansi t.cpp
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
int a [3];
int foo (int i, va_list *pva)
{
a [i++] = va_arg (*pva, int);
return i;
}
void bar (int i, va_list va)
{
a [i++] = va_arg (va, int);
#ifdef va_copy
va_list cpy;
va_copy (cpy, va);
va_end (va);
i = foo (i, &cpy);
va_copy (va, cpy);
va_end (cpy);
#else
i = foo (i, &va);
#endif
a [i++] = va_arg (va, int);
}
void baz (int i, ...)
{
va_list va;
va_start (va, i);
bar (i, va);
va_end (va);
}
int main ()
{
baz (0, 1, 2, 3);
printf ("%d, %d, %d\n", a [0], a [1], a [2]);
assert (1 == a [0]);
assert (2 == a [1]);
assert (3 == a [2]);
}
g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-47)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
t.cpp: In function `void bar(int, __va_list_tag*)':
t.cpp:25: cannot convert `__va_list_tag**' to `__va_list_tag (*)[1]' for
argument `2' to `int foo(int, __va_list_tag (*)[1])'
--
Summary: bogus error passing &va_list to va_list*
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: x86_64-redhat-linux
GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20951