[Freeciv-Dev] (PR#3427) Remove noreturn attribute
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[rp - Wed Mar 5 19:45:48 2003]:
> On Fri, Feb 28, 2003 at 02:14:37AM -0800, Raimar Falke wrote:
> > On Fri, Feb 28, 2003 at 01:13:39AM -0800, Jason Short wrote:
> > > Raimar Falke wrote:
> > > > On Thu, Feb 27, 2003 at 09:19:18AM -0800, Reinier Post wrote:
> > >
> > > > Next version without variadic arguments. Tested with gcc and icc6.
> > >
> > > > +#define die(format, args...) \
> > > > + do{ \
> > > > + real_die(format , ## args); \
> > > > + exit(EXIT_FAILURE); \
> > > > + } while(0)
> > > > +
> > >
> > > Um, those are variadic arguments.
> >
> > *reading* Yes. __VA_ARGS__ is the version from C99. "## args" is the
> > gcc extension.
> >
> > So since we don't want/can require a C99 compiler I will propose again
> > my first fix.
> >
> > Raimar
>
> I do not understand. Neither are C89 compliant.
> We have variadic arguments of functions in the code already.
> Keep Freeciv C89 compliant as long as you don't have an actual reason
> to break it. BTW I think it's ridiculous to use macros for cases
> like this.
The issue here is with compiler warnings and gcc attributes.
die() has the gcc "noreturn" attribute, meaning gcc will be able to
optimize things slightly better and will also change its warnings: for
instance:
int x;
if (foo) {
die(...);
} else {
x = 1;
}
x++;
will not have a "variable not initialized" warning, while
die(...);
return 0;
will give a "statement not reached" warning. All of this is beneficial.
But when compiling under icc or another compiler, this gcc-compliant
code will now give "variable not initialized" and "end of function
reached with no return" warnings. This makes it less convenient to use
icc warnings for debugging.
Unfortunately we have not found a good solution to this problem.
Fortunately, it is really a rather trivial problem - just a few extra
lines of code, and a little bit of extra help from the compiler in
debugging.
jason
- [Freeciv-Dev] (PR#3427) Remove noreturn attribute,
Jason Short <=
|
|