On Friday,  1 September 2006 at 23:26, Per Inge Mathisen wrote:
> On 9/1/06, Christian Ohm <[EMAIL PROTECTED]> wrote:
> >This patch consists mostly of casts to make Warzone compile with g++
> >-fpermissive. I'll reply to this mail with comments on a few changes.
> 
> You forgot to add an actual return value in debug().

Intentionally omitted, not forgotten. The problem is the definition of
ASSERT which looks like this:

   (void)( x ? 0 : debug( LOG_ERROR, __VA_ARGS__ ) );

On this (and the next, similar) line g++ complains about "error:
‘debug(LOG_ERROR, ((const char*)"blkInitialise: Blocks already
initialised"))’ has type ‘void’ and is not a throw-expression". So debug
needs a non-void return type, and this was the only solution I've found
(casting in the macro doesn't work, then g++ complains about void not
being ignored like it should).

> BTW, why are you compiling with g++??

To try some C++ stuff like GUI libraries - well, that's my intention,
we'll see how far I get this time...

And it finds bugs like the following:

lib/script/script_parser.y, line 4089:
        *STRSTACK[CURSTACKSTR] = (char)MALLOC(MAXSTRLEN);

where the first byte of STRSTACK[CURSTACKSTR] gets overwritten by a
truncated address. The only reason this works is that the next line
overwrites the overwritten string, and since STRSTACK is defined as

extern char STRSTACK[MAXSTACKLEN][MAXSTRLEN];

the MALLOC isn't even necessary and the adress used in the next line is
actually valid.

OK, that one has no consequences (probably the only reason it's still in
the code), but some of those I commented on in this thread look like
they could.

-- 
volcano, n.:
        A mountain with hiccups.

_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to