lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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