Article View: gnu.gcc.bug
Article #1259bad warnings with sparc <stdarg.h> and -Wcast-align (gcc 2.2.2)
From: Chris Metcalf
Date: Tue, 06 Oct 1992 19:01
Date: Tue, 06 Oct 1992 19:01
54 lines
2525 bytes
2525 bytes
The following short program generates four warnings of the form
"warning: cast increases required alignment of target type" when
compiled with sparc gcc 2.2.2 -Wcast-align:
#include <stdarg.h>
void
foo(char *arg1, ...)
{
va_list ap;
char *p;
va_start(ap, arg1);
p = va_arg(ap, char *); /* warnings flagged here */
}
The errors come from the definition of va_arg in <va-sparc.h>. Since the
usage here is correct, the errors should be suppressed, which can be done
by casting the offending pointers to (void *). Simply making pvar be a
"void *" fails since we need the increment-by-one property of "char *"
in va_arg(). The generated code is the same (not surprisingly).
*** 1.1 1992/10/07 02:53:12
--- va-sparc.h 1992/10/07 02:53:43
***************
*** 53,64 ****
({ TYPE __va_temp; \
((__builtin_classify_type (__va_temp) >= 12) \
? ((pvar) += __va_rounded_size (TYPE *), \
! **(TYPE **) ((pvar) - __va_rounded_size (TYPE *))) \
: __va_rounded_size (TYPE) == 8 \
? ({ union {TYPE d; int i[2];} u; \
! u.i[0] = ((int *) (pvar))[0]; \
! u.i[1] = ((int *) (pvar))[1]; \
(pvar) += 8; \
u.d; }) \
: ((pvar) += __va_rounded_size (TYPE), \
! *((TYPE *) ((pvar) - __va_rounded_size (TYPE)))));})
--- 53,64 ----
({ TYPE __va_temp; \
((__builtin_classify_type (__va_temp) >= 12) \
? ((pvar) += __va_rounded_size (TYPE *), \
! **(TYPE **) (void *) ((pvar) - __va_rounded_size (TYPE *))) \
: __va_rounded_size (TYPE) == 8 \
? ({ union {TYPE d; int i[2];} u; \
! u.i[0] = ((int *) (void *) (pvar))[0]; \
! u.i[1] = ((int *) (void *) (pvar))[1]; \
(pvar) += 8; \
u.d; }) \
: ((pvar) += __va_rounded_size (TYPE), \
! *((TYPE *) (void *) ((pvar) - __va_rounded_size (TYPE)))));})
--
Chris Metcalf, MIT Laboratory for Computer Science
metcalf@cag.lcs.mit.edu // +1 (617) 253-7766
Technical Details
Message-ID:
<9210070301.AA03708@catfish.LCS.MIT.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!catfish.lcs.mit.edu!metcalfShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!catfish.lcs.mit.edu!metcalf From: metcalf@catfish.lcs.mit.edu (Chris Metcalf) Subject: bad warnings with sparc <stdarg.h> and -Wcast-align (gcc 2.2.2) Message-ID: <9210070301.AA03708@catfish.LCS.MIT.EDU> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 6 Oct 1992 19:01:32 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 55