Article View: gnu.gcc.bug
Article #279Bug report - GCC 2.2.2
From: Robert Paige Rendell
Date: Mon, 27 Jul 1992 02:02
Date: Mon, 27 Jul 1992 02:02
74 lines
2171 bytes
2171 bytes
This is a bug report for gcc 2.2.2 to do with functions returning structures
by value with vararg parameter lists.
It seems that the vararg list gets corrupted if the function returns a
structure (by value), but not if it returns a simple data type. This is a
minimal program that demonstrated the bug on our system (DECstation5000
running Ultrix 4.2)
================================================================================
#include <stdio.h>
#include <stdarg.h>
struct spurious
{
int anumber;
};
int first(char *fmt, ...)
{
int pos, number;
va_list args;
int dummy;
va_start(args, fmt);
for (pos = 0; fmt[pos]; pos++)
if (fmt[pos] == 'i')
{
number = va_arg(args, int);
printf("%d", number);
}
else
putchar(fmt[pos]);
va_end(args);
putchar('\n');
return dummy;
}
struct spurious second(char *fmt, ...) /* same as 'first', except for the */
{ /* return type */
int pos, number;
va_list args;
struct spurious dummy;
va_start(args, fmt);
for (pos = 0; fmt[pos]; pos++)
if (fmt[pos] == 'i')
{
number = va_arg(args, int);
printf("%d", number);
}
else
putchar(fmt[pos]);
va_end(args);
putchar('\n');
return dummy;
}
main()
{
first("hi there this works", 5, 20);
second("hi there this works", 5, 20); /* no, it doesn't */
}
================================================================================
The output I got from this program was:
h5 there th20s works
h268435456 there th5s works
Thanks for your time, and sorry if you're already aware of this bug.
Have fun,
Rob R.
\((/
~oo~
/))\
Technical Details
Message-ID:
<9207260602.AA26740@bruce>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!bruce.cs.monash.edu.au!rendellShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!bruce.cs.monash.edu.au!rendell From: rendell@bruce.cs.monash.edu.au (Robert Paige Rendell) Subject: Bug report - GCC 2.2.2 Message-ID: <9207260602.AA26740@bruce> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Mon, 27 Jul 1992 02:02:36 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 77