Integer constant does not have type integer

Sat Feb 27, 2021 3:58 pm

I was trying to track down a crash in the black cats mod and created a debug build of GZDoom.
Although this is in fact unrelated, it seems that somehow, integer constants are not strictly regarded as integers.
Steps to reproduce:

1 Build a debug build of the current GZDoom master downloaded straight from the repository.
2. Load a directory or PK3 containing this script:
Code:
class bug : actor
{
    const e = 8;

    protected int i;

    void X_Bug()
    {
        int ee = e;

        i = max(1, ee);
    }
}
3. Start GZDoom and use -file to load it.
4. This one compiles with no issues.
5. Now instead use this script:
Code:
class bug : actor
{
    const e = 8;

    protected int i;

    void X_Bug()
    {
        i = max(1, e);
    }
}
6. Expected result: game starts
7. Actual result (full log below):
Code:
LoadActors: Load actor definitions.
gzdoom: /home/martin/Games/Engines/GZDoom/gzdoom/src/common/scripting/backend/codegen.cpp:5264: virtual FxExpression* FxMinMax::Resolve(FCompileContext&): Assertion `value.Type == ValueType' failed.
Aborted (core dumped)

Full log:
Code:
martin@freddie:~/Games/Engines/GZDoom/gzdoom-master$ ./gzdoom -iwad doom -file z
GZDoom g4.6pre-130-gfeb3520ee - 2021-02-26 10:37:55 +0100 - SDL version
Compiled on Feb 27 2021

OS: Linux Mint 20, Linux 5.4.0-66-generic on x86_64
M_LoadDefaults: Load system defaults.
W_Init: Init WADfiles.
 adding /home/martin/Games/Engines/GZDoom/gzdoom-master/gzdoom.pk3, 632 lumps
 adding /home/martin/Games/Engines/GZDoom/gzdoom-master/game_support.pk3, 2514 lumps
 adding /usr/share/doom/doom.wad, 2306 lumps
 adding /home/martin/Games/Engines/GZDoom/gzdoom-master/game_widescreen_gfx.pk3, 39 lumps
 adding z, 1 lumps
I_Init: Setting up machine state.
CPU Vendor ID: GenuineIntel
  Name: Intel(R) Xeon(R) CPU E5345 @ 2.33GHz
  Family 6, Model 15, Stepping 11
  Features: SSE2 SSE3 SSSE3 HyperThreading
V_Init: allocate screen.
S_Init: Setting up sound.
I_InitSound: Initializing OpenAL
  Opened device EMU20k1 [Sound Blaster X-Fi Series] Analogue Stereo
  EFX enabled
ST_Init: Init startup screen.
Checking cmd-line parameters...
S_InitData: Load sound definitions.
G_ParseMapInfo: Load map definitions.
Texman.Init: Init texture manager.
ParseTeamInfo: Load team definitions.
LoadActors: Load actor definitions.
gzdoom: /home/martin/Games/Engines/GZDoom/gzdoom/src/common/scripting/backend/codegen.cpp:5264: virtual FxExpression* FxMinMax::Resolve(FCompileContext&): Assertion `value.Type == ValueType' failed.
Aborted (core dumped)=======================================================================================================.......]
martin@freddie:~/Games/Engines/GZDoom/gzdoom-master$


If this is getting through in non-debug builds, who knows what trouble it might be subtly causing :shrug:

Re: Integer constant does not have type integer

Sat Feb 27, 2021 5:10 pm

Looks like a bogus assert. The expression is constant and the compiler tries to optimize it out, but something with the type does not seem to do what the assert expects.