This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/30357] New: Enum typecast warning


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;
};


-- 
           Summary: Enum typecast warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mareq at mailbox dot sk


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]