Issue #143 new

test_enum_size makes invalid assumptions about size and signedness

Danek Duvall
created an issue

Again with the Solaris Studio compiler: test_enum_size() appears to make two assumptions. One is that enum values are unsigned, the other is that the size of an enum is the same as sizeof(long).

With Studio, using 4294967295U as an enum value ends up as -1, even with the "U", and this appears to be allowed by the C spec. Looks like this is a problem with test_enum_bug118

Also, Studio treats all enum values as four bytes, even in 64-bit mode (when longs are 8 bytes), so the extra four test cases in test_enum_size() wouldn't fit.

I could modify the tests to skip the same cases that they already do on Windows, but it's really a compiler issue, not a platform issue -- if I use gcc, the test cases pass as-is -- and I'm not sure how I'd tell what the compiler was (or what its properties were) at that point, anyway.

But it's also not clear to me what this is testing for. Given that you can't actually expect these tests to succeed, is there a reason that we're testing for their success on any platform?

Comments (1)

  1. Armin Rigo

    The tests are generally written assuming gcc (or possibly clang) everywhere except on Windows. I know it's wrong but we pass extra arguments in the tests like "-Werror", which I bet don't work out of the box on all other compilers. Feel free to skip the annoying tests if you're somehow detecting a non-gcc compiler. In this case, the goal of the test is to check the logic that decides if an enum is a signed or unsigned, and int or long (all four cases are possible with gcc).

  2. Log in to comment