[PATCH] msvcp120: Avoid type conversion warnings in test_tr2_sys__dir_operation.

Piotr Caban piotr.caban at gmail.com
Thu May 7 03:14:07 CDT 2020

Hi Gerald,

I think I would prefer to go with additional enum value approach. Even 
the C11 standard gives such assignment as an example of when compiler 
may generate a warning (Annex I, Common warnings in final draft). It 
also states that type = 0xdeadbeef is an example of "undefined behavior" 
(signed integer overflow).

Something like this should work:
enum file_type {
     file_type_test_init = -1,
err = 0xdeadbeef;
type = file_type_test_init;


On 5/6/20 10:40 PM, Gerald Pfeifer wrote:
> On Tue, 5 May 2020, Piotr Caban wrote:
>>> +    type = 0xdeadbeef;
>> I guess this assignment will work on all compilers. Isn't assigning
>> the value outside of enum range unspecified in C standard?
> Based on your question I dug into the C11 standard and found
>    "An identifier declared as an enumeration constant has type int."
> So that should not be a concern.  And if it turns out it ever triggers
> something, we can...
>> I don't know if it's a valid concern but I'm worried it may still cause
>> a warning on some compilers (I don't know any that actually warns in
>> this case). How about adding a new value to enum and using it in tests
>> for uninitialized value (or just using 0)?
> ...always follow the approach you outline (which will be easier than
> since there is a single assignment to adjust, not the current double
> assignment).
> If after the above you'd still like to see us use 0x0 or an distinct
> member of the enum (how would you call that?) let me know and I'll cook
> a new patch.
> Gerald

More information about the wine-devel mailing list