Pelles C > Bug reports

Bug and Access Violations

(1/3) > >>

Kobold:
Hi  :)

Attached is a small file (no dependencies) that demonstrates 2 bugs in Pelles C 11/12.

First is a false warning #2272: '0' is not a member of 'TestEnum (aka enum (no name))'

Second is one of many access violations I encountered in an attempt to port Jagged Alliance 2 to Pelles C.
I guess it's the same problem in most cases, so fixing this specific compiler bug should fix the problem in general.

Please read the comments for details.

I compiled everything in the IDE, didn't test if there is a difference when compiling from the shell.

Thanks for looking into it. Have a nice day.

frankie:
Hello Kobold.
The enum test in your example doesn't produce any warnings. The following patched code does:

--- Code: ---typedef enum
{
EOPTION0=1, //Don't produce any member == 0
EOPTION1,
EOPTION2,
EOPTION3,
EOPTION4,
EOPTION5,
EOPTION6,
ENUMOPTIONS
} TestEnum;

TestEnum e = 0;        //Warning is issued here.

--- End code ---
In any case the value 0 is not strictly a member of the enum, and it is just a warning, you can disable it using pragmas.
IMHO the abuse made in many codes to force enum values that are not declared in the enumeration should be an error, why you use an enumeration if then you use arbitrary values? Just define an integer and some constants...  ::)

For the assembler part confirmed the bug.
Just commenting the line:

--- Code: ---RightSkipLoop: // skip along until we hit and end-of-line marker

--- End code ---
Produce an error, and the warning about to limited portability of assembler code, but not crash with 'fatal error: Internal error: 'Access violation' at 0x00.........'. This means that the problem is at code generation or optimization level.

Kobold:

--- Quote from: frankie on July 11, 2023, 04:28:34 PM ---The enum test in your example doesn't produce any warnings.

--- End quote ---

Here's the exact output I get in the IDE:

--- Code: ---Building ja2_crash.obj.
D:\Dev\Projekte\JaggedAlliance2\ja2_crash.c(31): warning #2272: '0' is not a member of 'TestEnum (aka enum (no name))'
D:\Dev\Projekte\JaggedAlliance2\ja2_crash.c(32): warning #2272: '0' is not a member of 'TestEnum (aka enum (no name))'
fatal error: Internal error: 'Access violation' at 0x000000013f3db492.
*** Error code: 1 ***
Done.

--- End code ---

Of course I could disable the warning. But I can't trust that the correct code was produced, the warning message makes me believe that it didn't interpret the code correctly and assumes a '0' where there is none.

Kobold:

--- Quote from: frankie on July 11, 2023, 04:28:34 PM ---why you use an enumeration if then you use arbitrary values?
--- End quote ---

As stated in the source comments, this is not a real-world example. It is based on real code that produced the warning, and I quickly hacked it together for demonstration of the problem. I don't want anyone to download and compile a giant project just to get my point across :)

There should be no "member of enum" check involved here in the first place. It doesn't matter where ENUMOPTIONS comes from, it is just substituted by a number used to set the size of an array, the array itself doesn't need to have any interrelation with the enum type definition.

frankie:

--- Quote from: Kobold on July 11, 2023, 04:36:16 PM ---Of course I could disable the warning. But I can't trust that the correct code was produced, the warning message makes me believe that it didn't interpret the code correctly and assumes a '0' where there is none.

--- End quote ---
Your concerns are shareable, the problem for me is that I don't get the error:

--- Code: ---Building ja2_crash.obj.
C:\ja2_crash\ja2_crash.c(74): warning #2007: Inline assembly code is not portable.
fatal error: Internal error: 'Access violation' at 0x00007ff6df939cf0.
*** Error code: 1 ***
Done.

--- End code ---
Are you using the last compiler version?
Are you sure that there are no installation problems on your machine?  :P

Navigation

[0] Message Index

[#] Next page

Go to full version