Bug 107377 - Warn about duplicate enum values?
Summary: Warn about duplicate enum values?
Status: RESOLVED DUPLICATE of bug 16186
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 13.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2022-10-24 13:38 UTC by Martin Liška
Modified: 2022-10-24 15:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2022-10-24 13:38:53 UTC
Noticed that while investigating PR107364:

enum processor_vendor
{
  VENDOR_INTEL = 1,
  VENDOR_AMD,
  VENDOR_ZHAOXIN,
  VENDOR_OTHER,
  VENDOR_CENTAUR,
  VENDOR_CYRIX,
  VENDOR_NSC,
  BUILTIN_VENDOR_MAX = VENDOR_OTHER,
  VENDOR_MAX
};

As one can see VENDOR_CENTAUR == 5, but VENDOR_MAX is also == 5 as BUILTIN_VENDOR_MAX points to 4 and thus VENDOR_MAX == 5.

Maybe we can warn about 2 enum values that have the same value and none of them is defined with '= some_value'. What do you think?
Comment 1 Andrew Pinski 2022-10-24 15:25:59 UTC
Dup of much older bug 16186.

*** This bug has been marked as a duplicate of bug 16186 ***