This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [build, ada] Allow Solaris bootstrap with C++ (PR bootstrap/49794)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: Arnaud Charlet <charlet at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Paolo Bonzini <bonzini at gnu dot org>, Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>, Ian Lance Taylor <iant at google dot com>, Tom Tromey <tromey at redhat dot com>
- Date: Thu, 21 Jul 2011 13:59:15 +0200
- Subject: Re: [build, ada] Allow Solaris bootstrap with C++ (PR bootstrap/49794)
- References: <yddbowonc44.fsf@manam.CeBiTec.Uni-Bielefeld.DE> <20110721065050.GA92514@adacore.com>
Arnaud,
>> * Similarly to IRIX 6, there was a mismatch in ada/init.c for the type
>> of the signal handler installed with sigaction. g++ also doesn't like
>> arithmetic on void * ;-)
>
> I'm a bit puzzled as to why the C compiler isn't complaining, and what
> error message the C++ compiler is generating, can you clarify?
I'd removed the previous build before copying the exact error message.
Here's what I get without the init.c change:
/vol/gcc/src/hg/trunk/local/gcc/ada/init.c: In function 'void __gnat_install_handler()':
/vol/gcc/src/hg/trunk/local/gcc/ada/init.c:1049:20: error: invalid conversion from 'void (*)(int, siginfo_t*, void*) {aka void (*)(int, siginfo*, void*)}' to 'void (*)(int)' [-fpermissive]
which is correct. <sys/signal.h> has
/*
* The signal handler routine can have either one or three arguments.
* Existing C code has used either form so not specifing the arguments
* neatly finesses the problem. C++ doesn't accept this. To C++
* "(*sa_handler)()" indicates a routine with no arguments (ANSI C would
* specify this as "(*sa_handler)(void)"). One or the other form must be
* used for C++ and the only logical choice is "(*sa_handler)(int)" to allow
* the SIG_* defines to work. "(*sa_sigaction)(int, siginfo_t *, void *)"
* can be used for the three argument form.
*/
/*
* Note: storage overlap by sa_handler and sa_sigaction
*/
struct sigaction {
int sa_flags;
union {
#ifdef __cplusplus
void (*_handler)(int);
#else
void (*_handler)();
#endif
#if defined(__EXTENSIONS__) || defined(_KERNEL) || \
(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
(_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
void (*_sigaction)(int, siginfo_t *, void *);
#endif
} _funcptr;
sigset_t sa_mask;
#ifndef _LP64
int sa_resv[2];
#endif
};
#define sa_handler _funcptr._handler
#define sa_sigaction _funcptr._sigaction
> Why is the code accepted by the C compiler in the first place?
... which explains why the C compiler accepts the code as is.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University