Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Chris Metcalf
Tue, 06 Oct 1992 19:01
bad warnings with sparc <stdarg.h> and -Wcast-align (gcc 2.2.2)
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads