Skip to content

[clang] Invalid rejection of enum arithmetic #84712

Closed
@davidstone

Description

The following valid translation unit

enum e1 {
	value = 0
};

enum e2 {
	a = 0,
	b = e1::value,
	c = a + b
};

is incorrectly rejected by clang when compiled in C++26 mode with

<source>:8:8: error: invalid arithmetic between different enumeration types ('e2' and 'e1')
    8 |         c = a + b
      |             ~ ^ ~
1 error generated.
Compiler returned: 1

See it live: https://godbolt.org/z/v4sG9YqMb

In earlier versions of C++, it incorrectly warns saying the conversion is deprecated.

This was accepted in clang 18.1.0, but is failing on current trunk (15e9478).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions