* problem with short in va_arg list with 2.95.1 gcc
@ 2000-01-07 22:51 Jim Terman
2000-01-08 2:19 ` Daniel Jacobowitz
2000-01-08 2:27 ` Franz Sirl
0 siblings, 2 replies; 3+ messages in thread
From: Jim Terman @ 2000-01-07 22:51 UTC (permalink / raw)
To: linuxppc-dev
I am having a problem with code that looks for type short in a va_arg list
when optimization is turned on. There is no problem with no optimization.
It compiles fine but produces an undefined reference to `__va_arg_type_violation'
which I assume is delibrate to flag an error. Is there a workaround besides
turning off optimizations?
If I compile the following file:
test.c
------
#include <stdarg.h>
#include <stdio.h>
void printout(short d, ...)
{
va_list arglist;
printf("%d ", d);
d = va_arg (arglist, short);
while (d)
{
printf("%s ", d);
d = va_arg (arglist, short);
}
}
int main()
{
printout(1, 2, 0);
printout(2, 3, 4, 0);
return 0;
}
with the command line:
> gcc -v -O test.c
Reading specs from /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/specs
gcc version 2.95.1 19990809 (prerelease)
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -DPPC -D__ELF__ -Dpowerpc -D__PPC__ -D__ELF__ -D__powerpc__ -D__PPC -D__powerpc -Acpu(powerpc) -Amachine(powerpc) -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D_CALL_SYSV -D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine(bigendian) -D_ARCH_PPC -D__unix__ -D__linux__ -Dunix -Dlinux -Asystem(unix) -Asystem(posix) test.c /tmp/ccnguSmk.i
GNU CPP version 2.95.1 19990809 (prerelease) (PowerPC GNU/Linux)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../ppc-redhat-linux/include
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../include/g++-3
/usr/local/include
End of omitted list.
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cc1 /tmp/ccnguSmk.i -quiet -dumpbase test.c -O -version -o /tmp/ccwsSAdv.s
GNU C version 2.95.1 19990809 (prerelease) (ppc-redhat-linux) compiled by GNU C version 2.95.1 19990809 (prerelease).
as -mppc -V -Qy -o /tmp/ccF8j30K.o /tmp/ccwsSAdv.s
GNU assembler version 2.9.5 (ppc-redhat-linux) using BFD version 2.9.5.0.14
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/collect2 -m elf32ppclinux -dynamic-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtbegin.o -L/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1 /tmp/ccF8j30K.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a -lc /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtend.o /usr/lib/crtn.o
/tmp/ccF8j30K.o: In function `printout':
/tmp/ccF8j30K.o(.text+0x60): undefined reference to `__va_arg_type_violation'
/tmp/ccF8j30K.o(.text+0x60): relocation truncated to fit: R_PPC_REL24 __va_arg_type_violation
collect2: ld returned 1 exit status
> gcc -v test.c
Reading specs from /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/specs
gcc version 2.95.1 19990809 (prerelease)
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -DPPC -D__ELF__ -Dpowerpc -D__PPC__ -D__ELF__ -D__powerpc__ -D__PPC -D__powerpc -Acpu(powerpc) -Amachine(powerpc) -D__CHAR_UNSIGNED__ -D_CALL_SYSV -D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine(bigendian) -D_ARCH_PPC -D__unix__ -D__linux__ -Dunix -Dlinux -Asystem(unix) -Asystem(posix) test.c /tmp/ccTOmkZu.i
GNU CPP version 2.95.1 19990809 (prerelease) (PowerPC GNU/Linux)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../ppc-redhat-linux/include
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../include/g++-3
/usr/local/include
End of omitted list.
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cc1 /tmp/ccTOmkZu.i -quiet -dumpbase test.c -version -o /tmp/ccUI6hGQ.s
GNU C version 2.95.1 19990809 (prerelease) (ppc-redhat-linux) compiled by GNU C version 2.95.1 19990809 (prerelease).
as -mppc -V -Qy -o /tmp/ccBIgJ3g.o /tmp/ccUI6hGQ.s
GNU assembler version 2.9.5 (ppc-redhat-linux) using BFD version 2.9.5.0.14
/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/collect2 -m elf32ppclinux -dynamic-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtbegin.o -L/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1 /tmp/ccBIgJ3g.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a -lc /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtend.o /usr/lib/crtn.o
>
--
______________________________________________________________________________
Jim Terman | 323 Vintage Park Dr. | Voice: (650) 356-5446
terman@ddi.com | Foster City, CA | Fax: (650) 356-5490
Diab-SDS, Inc. | 94404 | web site - http://www.ddi.com
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with short in va_arg list with 2.95.1 gcc
2000-01-07 22:51 problem with short in va_arg list with 2.95.1 gcc Jim Terman
@ 2000-01-08 2:19 ` Daniel Jacobowitz
2000-01-08 2:27 ` Franz Sirl
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2000-01-08 2:19 UTC (permalink / raw)
To: linuxppc-dev
[FAQ]
short is not a legal type for va_arg. Instead, use
(short)va_arg(arglist, int).
On Fri, Jan 07, 2000 at 02:51:19PM -0800, Jim Terman wrote:
>
> I am having a problem with code that looks for type short in a va_arg list
> when optimization is turned on. There is no problem with no optimization.
> It compiles fine but produces an undefined reference to `__va_arg_type_violation'
> which I assume is delibrate to flag an error. Is there a workaround besides
> turning off optimizations?
>
> If I compile the following file:
> test.c
> ------
> #include <stdarg.h>
> #include <stdio.h>
>
> void printout(short d, ...)
> {
> va_list arglist;
>
> printf("%d ", d);
> d = va_arg (arglist, short);
> while (d)
> {
> printf("%s ", d);
> d = va_arg (arglist, short);
> }
> }
>
> int main()
> {
> printout(1, 2, 0);
> printout(2, 3, 4, 0);
> return 0;
> }
>
> with the command line:
>
> > gcc -v -O test.c
> Reading specs from /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/specs
> gcc version 2.95.1 19990809 (prerelease)
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -DPPC -D__ELF__ -Dpowerpc -D__PPC__ -D__ELF__ -D__powerpc__ -D__PPC -D__powerpc -Acpu(powerpc) -Amachine(powerpc) -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D_CALL_SYSV -D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine(bigendian) -D_ARCH_PPC -D__unix__ -D__linux__ -Dunix -Dlinux -Asystem(unix) -Asystem(posix) test.c /tmp/ccnguSmk.i
> GNU CPP version 2.95.1 19990809 (prerelease) (PowerPC GNU/Linux)
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../ppc-redhat-linux/include
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/include
> /usr/include
> End of search list.
> The following default directories have been omitted from the search path:
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../include/g++-3
> /usr/local/include
> End of omitted list.
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cc1 /tmp/ccnguSmk.i -quiet -dumpbase test.c -O -version -o /tmp/ccwsSAdv.s
> GNU C version 2.95.1 19990809 (prerelease) (ppc-redhat-linux) compiled by GNU C version 2.95.1 19990809 (prerelease).
> as -mppc -V -Qy -o /tmp/ccF8j30K.o /tmp/ccwsSAdv.s
> GNU assembler version 2.9.5 (ppc-redhat-linux) using BFD version 2.9.5.0.14
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/collect2 -m elf32ppclinux -dynamic-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtbegin.o -L/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1 /tmp/ccF8j30K.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a -lc /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtend.o /usr/lib/crtn.o
> /tmp/ccF8j30K.o: In function `printout':
> /tmp/ccF8j30K.o(.text+0x60): undefined reference to `__va_arg_type_violation'
> /tmp/ccF8j30K.o(.text+0x60): relocation truncated to fit: R_PPC_REL24 __va_arg_type_violation
> collect2: ld returned 1 exit status
>
> > gcc -v test.c
> Reading specs from /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/specs
> gcc version 2.95.1 19990809 (prerelease)
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -DPPC -D__ELF__ -Dpowerpc -D__PPC__ -D__ELF__ -D__powerpc__ -D__PPC -D__powerpc -Acpu(powerpc) -Amachine(powerpc) -D__CHAR_UNSIGNED__ -D_CALL_SYSV -D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine(bigendian) -D_ARCH_PPC -D__unix__ -D__linux__ -Dunix -Dlinux -Asystem(unix) -Asystem(posix) test.c /tmp/ccTOmkZu.i
> GNU CPP version 2.95.1 19990809 (prerelease) (PowerPC GNU/Linux)
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../ppc-redhat-linux/include
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/include
> /usr/include
> End of search list.
> The following default directories have been omitted from the search path:
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/../../../../include/g++-3
> /usr/local/include
> End of omitted list.
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/cc1 /tmp/ccTOmkZu.i -quiet -dumpbase test.c -version -o /tmp/ccUI6hGQ.s
> GNU C version 2.95.1 19990809 (prerelease) (ppc-redhat-linux) compiled by GNU C version 2.95.1 19990809 (prerelease).
> as -mppc -V -Qy -o /tmp/ccBIgJ3g.o /tmp/ccUI6hGQ.s
> GNU assembler version 2.9.5 (ppc-redhat-linux) using BFD version 2.9.5.0.14
> /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/collect2 -m elf32ppclinux -dynamic-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtbegin.o -L/usr/lib/gcc-lib/ppc-redhat-linux/2.95.1 /tmp/ccBIgJ3g.o /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a -lc /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/libgcc.a /usr/lib/gcc-lib/ppc-redhat-linux/2.95.1/crtend.o /usr/lib/crtn.o
> >
> --
> ______________________________________________________________________________
> Jim Terman | 323 Vintage Park Dr. | Voice: (650) 356-5446
> terman@ddi.com | Foster City, CA | Fax: (650) 356-5490
> Diab-SDS, Inc. | 94404 | web site - http://www.ddi.com
>
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| SCS Class of 2002 |
| Debian GNU/Linux Developer __ Carnegie Mellon University |
| dan@debian.org | | dmj+@andrew.cmu.edu |
\--------------------------------/ \--------------------------------/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with short in va_arg list with 2.95.1 gcc
2000-01-07 22:51 problem with short in va_arg list with 2.95.1 gcc Jim Terman
2000-01-08 2:19 ` Daniel Jacobowitz
@ 2000-01-08 2:27 ` Franz Sirl
1 sibling, 0 replies; 3+ messages in thread
From: Franz Sirl @ 2000-01-08 2:27 UTC (permalink / raw)
To: Jim Terman, linuxppc-dev
Am Fre, 07 Jan 2000 schrieb Jim Terman:
>I am having a problem with code that looks for type short in a va_arg list
>when optimization is turned on. There is no problem with no optimization.
>It compiles fine but produces an undefined reference to `__va_arg_type_violation'
>which I assume is delibrate to flag an error. Is there a workaround besides
>turning off optimizations?
>
>If I compile the following file:
>test.c
>------
>#include <stdarg.h>
>#include <stdio.h>
>
>void printout(short d, ...)
>{
> va_list arglist;
>
> printf("%d ", d);
> d = va_arg (arglist, short);
> while (d)
> {
> printf("%s ", d);
> d = va_arg (arglist, short);
> }
>}
>
>int main()
>{
> printout(1, 2, 0);
> printout(2, 3, 4, 0);
> return 0;
>}
There's no such thing like va_arg(arglist, short) in standard C, you can only
use default promotion types and typedef's thereof. So you have to use (short)
va_arg(arglist, int) here.
Franz.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-01-08 2:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-01-07 22:51 problem with short in va_arg list with 2.95.1 gcc Jim Terman
2000-01-08 2:19 ` Daniel Jacobowitz
2000-01-08 2:27 ` Franz Sirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).