> -----Original Message-----
> From: David Brown [mailto:[email protected]]
> Sent: 19 March 2014 15:47
> To: Paulo Matos; [email protected]
> Subject: Re: returning short-enum and truncate doesn't trigger
> conversion warning
>
>
> Usually the discovery of bugs gets discussed on the help list - fixes
> for the bugs are an issue for the developers list. And it is
> certainly a "help" issue until we know you have found a bug.
>
Sure, I will make sure I submit these questions to gcc-help first.
> >
> >>>
> >>> enum xpto
> >>> {
> >>> A = 0,
> >>> B = 1,
> >>> X = 512
> >>> };
> >>>
> >>> extern void print (unsigned int);
> >>>
> >>> unsigned char bar (enum xpto a)
> >>> {
> >>> print (sizeof (unsigned char));
> >>> print (sizeof (enum xpto));
> >>> return a;
> >>> }
> >>
> >> The sizeof operator returns an integer of type size_t (typically
> the
> >> same as unsigned int or unsigned long, depending on the platform
> >> details). But the compiler can see that the particular values in
> >> question - 1 and 2 - can be converted to unsigned int without loss
> of
> >> precision of changing the value. Therefore no warning is giving.
> >>
> >
> > 512 cannot be converted to an unsigned char without loss of
> precision.
> > The prints are actually not relevant for the question. They were
> just used for me to confirm the sizes of the types.
>
> Not only are the prints not relevant, but they hid the real issue - I
> missed the point of your question!
>
> Conversions involving enumerations are not listed in the documentation
> for -Wconversion, but it would be nice to get a warning here. Filing
> it as an enhancement request seems reasonable.
>
Will report as an enhancement.
Thanks,
Paulo Matos