Bug 27534 - Warning on passing pointer to va_list
Summary: Warning on passing pointer to va_list
Status: RESOLVED DUPLICATE of bug 14557
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.5
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-10 15:43 UTC by Mark Gordon
Modified: 2006-05-10 15:46 UTC (History)
6 users (show)

See Also:
Host: powerpc-unknown-linux-gnu
Target: powerpc-unknown-linux-gnu
Build: powerpc-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Gordon 2006-05-10 15:43:16 UTC
Attempting to pass a pointer to a va_list variable to a function expecting such a pointer causes a warning about passing a pointer of incompatible type.

markg@home ~/work/ffdev $ gcc -v -save-temps -ansi -pedantic -Wall -W -O -c t.c
Reading specs from /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/specs
Configured with: /var/tmp/portage/gcc-3.4.5-r1/work/gcc-3.4.5/configure --prefix=/usr --bindir=/usr/powerpc-unknown-linux-gnu/gcc-bin/3.4.5 --includedir=/usr/lib/gcc/powerpc-unknown-linux
-gnu/3.4.5/include --datadir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/3.4.5 --mandir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/3.4.5/man --infodir=/usr/share/gcc-data/powerpc-unk
nown-linux-gnu/3.4.5/info --with-gxx-include-dir=/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include/g++-v3 --host=powerpc-unknown-linux-gnu --build=powerpc-unknown-linux-gnu --disable-a
ltivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --enable-languages=c,c++,java,f77 -
-enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)
 /usr/libexec/gcc/powerpc-unknown-linux-gnu/3.4.5/cc1 -E -quiet -v -D__unix__ -D__gnu_linux__ -D__linux__ -Asystem=linux -Asystem=unix -Asystem=posix t.c -ansi -pedantic -Wall -W -O -o t.
i
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/../../../../powerpc-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include
 /usr/include
End of search list.
 /usr/libexec/gcc/powerpc-unknown-linux-gnu/3.4.5/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -ansi -auxbase t -O -pedantic -Wall -W -ansi -version -o t.s
GNU C version 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9) (powerpc-unknown-linux-gnu)
        compiled by GNU C version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64407
t.c:3: warning: unused parameter 'arg'
t.c: In function `bar':
t.c:9: warning: passing arg 1 of `foo' from incompatible pointer type
 /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/../../../../powerpc-unknown-linux-gnu/bin/as -mppc -many -V -Qy -o t.o t.s
GNU assembler version 2.16.1 (powerpc-unknown-linux-gnu) using BFD version 2.16.1
markg@home ~/work/ffdev $ cat t.i
# 1 "t.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.c"
# 1 "/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include/stdarg.h" 1 3 4
# 43 "/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 "/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 2 "t.c" 2

void foo(va_list *arg)
{
}

void bar(va_list arg)
{
  foo(&arg);
}
markg@home ~/work/ffdev $ gcc -v
Reading specs from /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/specs
Configured with: /var/tmp/portage/gcc-3.4.5-r1/work/gcc-3.4.5/configure --prefix=/usr --bindir=/usr/powerpc-unknown-linux-gnu/gcc-bin/3.4.5 --includedir=/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include --datadir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/3.4.5 --mandir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/3.4.5/man --infodir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/3.4.5/info --with-gxx-include-dir=/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.5/include/g++-v3 --host=powerpc-unknown-linux-gnu --build=powerpc-unknown-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --enable-languages=c,c++,java,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)
markg@home ~/work/ffdev $

The warning about the unused variable is expected. The real code (much more complex) from which this was cut down used the variable and still generated the warning about incompatible pointer type.

The standard says that vl_list should be an object type, and others on the news group comp.lang.c agree that my code is valid. See thread http://groups.google.com/group/comp.lang.c/browse_frm/thread/e64d6ffd19ab7ae3/faf78d3f5fb3acfe?lnk=st&q=group%3Acomp.lang.c+insubject%3Ava_list&rnum=1&hl=en#faf78d3f5fb3acfe
Comment 1 Andrew Pinski 2006-05-10 15:46:50 UTC
It is an object type.  An array is an object type.

*** This bug has been marked as a duplicate of 14557 ***