This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: c/4152: Incorrect code for va_arg(x,char) and va_arg(x,short) on SH


At 15:19 28.08.2001, Schirmer, Hartmut wrote:
> > -----Original Message-----
> > From: sirl@gcc.gnu.org [mailto:sirl@gcc.gnu.org]
> > Sent: Tuesday, August 28, 2001 10:12 AM
> > To: SchirmerH@innovative-systems.de; gcc-bugs@gcc.gnu.org;
> > gcc-prs@gcc.gnu.org; nobody@gcc.gnu.org
> > Subject: Re: c/4152: Incorrect code for va_arg(x,char) and
> > va_arg(x,short) on SH
> >
> >
> > Synopsis: Incorrect code for va_arg(x,char) and va_arg(x,short) on SH
> >
> > State-Changed-From-To: open->closed
> > State-Changed-By: sirl
> > State-Changed-When: Tue Aug 28 01:12:22 2001
> > State-Changed-Why:
> >     The C code is invalid (thus the warning), please resubmit
> > (if the problem persists) with valid C, eg.
> >
> >     value = (char) va_arg (m, int);
> >
> >
> > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4152&database=gcc
> >
>
>Thanks for your analysis.
>What does 'invalid' mean in this case ?
>Not covered by C89, not by C99 or not
>covered by GNU-C ?

C standards (C89 and later which have va_arg) specify that anything passed 
through '...' is fully promoted.


>The provided code works just fine using
>gcc 2.95 (x86 & SH) but fails with an
>exception when compiled with gcc 3.0.1 on
>SH target.

I wonder how you could compile your code, cause I looked it up and in 
gcc-2.96, gcc-3.0.x and gcc-3.1 it is an error (issued in gcc/builtins.c), 
not a warning. Are you sure you use a clean code base?


>If it's invalid in a way GCC can generate a null
>pointer access there should be an error, not a
>warning.

It is an error in clean GCC.


>I tried all combinations and only thoese with
>sizeof(type) < sizeof(int) failed.
>
>I still think gcc is wrong here. It used to
>work right and still could work right.

No, because allowing this leads to extremely hard-to-track-down bugs if you 
write code running on a lot of platforms.

Franz.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]