https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30357

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-11-21
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=92159
     Ever confirmed|0                           |1

--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Marek Chovanec from comment #0)
> I would appreciate adding the enumeration typecast warnings. I mean:
> When I cast one enum to another and the first enum is not a subset of the
> second warning will be shown.
> 
> Example:
> 
> enum EParent
> {
>   EP_VAL0 = 0,
>   EP_VAL1 = 1,
>   EP_VAL2 = 2
> };
> 
> enum EChild
> {
>   EC_VAL0 = 0,
>   EC_VAL1 = 1
> };
> 
> int main()
> {
>   EChild childValue;
>   EParent parentValue;
> 
>   ...
> 
>   childValue = (EChild)parentValue; // Warning, because value 2 is not
> present in EChild.
> 
>   parentValue = (EParent)childValue; // Ok, because all EChild values are
> present in EParent.
> 
>   return 0;
> };

At least as far as this particular testcase goes, there's a warning from
-Wuninitialized at least... if you initialize parentValue to EP_VAL2 like I
think you intended, I can confirm that there are no warnings then, even after
-Wenum-conversion was added for bug 78736. Since that was for just C, though,
and this is C++, I guess that would make this bug 92159? But that was closed as
WORKSFORME though... I dunno, I'll just confirm this as separate for now...

Reply via email to