[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bug in gcc?
- From: Glenn Maynard <glenn@...>
- Date: Wed, 4 Apr 2007 18:10:07 -0400
On Wed, Apr 04, 2007 at 09:37:08PM +0100, David Given wrote:
> [1] Notice that 'usually'? This is the reason why x("hi") works. In an
> incredibly brain-damaged fit of, well, something, the C++ designers decided
> that it would be convenient if constant strings could be implicitly cast to
> char*. But this only happens if the constant string is *directly* cast to a
> char*. If you do an operation on it first, the const char* type is used
> instead. So:
(A convenient way to introduce bugs that cause runtime crashes, or to write
bad, non-const-correct code, instead of catching things at compile-time ...)
> This is probably because the compiler needs to be told that statements after
> that line are unreachable, otherwise it's reachable-code algorithms will get
> confused and you'll get spurious warnings. gcc allows you to mark a function
> as not returning with __attribute__ ((__noreturn__)), but that's hideously
> non-portable.
Any compiler that wants to determine whether a function returns needs to
have a noreturn attribute or something equivalent; both gcc and VC do.
No mature, commercial-quality compiler can complain about not returning
without providing a mechanism to tell the compiler about functions that
don't return. (Maybe Lua wants to compile without warnings on poor
compilers. Up to them. :)
--
Glenn Maynard