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

            Bug ID: 115371
           Summary: Hard to decode error message when fixed underlying
                    type of enum is not declared
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kamil_tym at wp dot pl
  Target Milestone: ---

The following one line program forgot #include <cstdint> for declaration of
std::uint64_t:

enum class E : std::uint64_t {};

g++ (with no extra diagnostic options) reports following errors and warnings
here:

<source>:1:6: warning: elaborated-type-specifier for a scoped enum must not use
the 'class' keyword
    1 | enum class E : std::uint64_t {};
      | ~~~~ ^~~~~
      |      -----
<source>:1:12: error: use of enum 'E' without previous declaration
    1 | enum class E : std::uint64_t {};
      |            ^
<source>:1:14: error: expected unqualified-id before ':' token
    1 | enum class E : std::uint64_t {};
      |              ^

The issue with the program is that std::uint64_t is not declared, but the error
messages make it really difficult to understand. clang for example produces a
more useful message: 'identifier std is not declared', correctly identifying
the issue.

Godbolt link to reproduction: https://godbolt.org/z/9fjjG9KE9

Reply via email to