You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang erroneously instantiates the enumerators twice in the case of a prior declaration.
As a consequence, the name lookup in the last line of the following example becomes ambiguous.
template <typename T>
structS {
enum E : T;
enum E : T { X = 5 };
};
auto x = S<char>::X;
Compiler output:
source>:7:19: error: reference to 'X' is ambiguous
7 | auto x = S<char>::X;
| ~~~~~~~~~^
<source>:4:18: note: candidate found by name lookup is 'S<char>::X'
4 | enum E : T { X = 5 };
| ^
<source>:4:18: note: candidate found by name lookup is 'S<char>::X'
1 error generated.
Another symptom is that diagnostics during instantiation appear twice in the output if a preceding opaque-enum-declaration exists:
template <typename T>
structS {
enum E : T;
enum E : T { X = 0x7FFFFF00 };
};
template structS<char>;
Compiler output:
<source>:4:22: warning: implicit conversion from 'int' to 'char' changes value from 2147483392 to 0 [-Wconstant-conversion]
4 | enum E : T { X = 0x7FFFFF00 };
| ^~~~~~~~~~
<source>:7:17: note: in instantiation of template class 'S<char>' requested here
7 | template struct S<char>;
| ^
<source>:4:22: error: enumerator value evaluates to 2147483392, which cannot be narrowed to type 'char' [-Wc++11-narrowing]
4 | enum E : T { X = 0x7FFFFF00 };
| ^
<source>:4:22: warning: implicit conversion from 'int' to 'char' changes value from 2147483392 to 0 [-Wconstant-conversion]
4 | enum E : T { X = 0x7FFFFF00 };
| ^~~~~~~~~~
<source>:4:22: error: enumerator value evaluates to 2147483392, which cannot be narrowed to type 'char' [-Wc++11-narrowing]
2 warnings and 2 errors generated.
Clang erroneously instantiates the enumerators twice in the case of a prior declaration.
As a consequence, the name lookup in the last line of the following example becomes ambiguous.
template <typename T>
structS {
enum E : T;
enum E : T { X = 5 };
};
auto x = S<char>::X;
Compiler output:
source>:7:19: error: reference to 'X' is ambiguous
7 | auto x = S<char>::X;
| ~~~~~~~~~^
<source>:4:18: note: candidate found by name lookup is 'S<char>::X'
4 | enum E : T { X = 5 };
| ^
<source>:4:18: note: candidate found by name lookup is 'S<char>::X'
1 error generated.
Another symptom is that diagnostics during instantiation appear twice in the output if a preceding opaque-enum-declaration exists:
template <typename T>
structS {
enum E : T;
enum E : T { X = 0x7FFFFF00 };
};
template structS<char>;
Compiler output:
<source>:4:22: warning: implicit conversion from 'int' to 'char' changes value from 2147483392 to 0 [-Wconstant-conversion]
4 | enum E : T { X = 0x7FFFFF00 };
| ^~~~~~~~~~
<source>:7:17: note: in instantiation of template class 'S<char>' requested here
7 | template struct S<char>;
| ^
<source>:4:22: error: enumerator value evaluates to 2147483392, which cannot be narrowed to type 'char' [-Wc++11-narrowing]
4 | enum E : T { X = 0x7FFFFF00 };
| ^
<source>:4:22: warning: implicit conversion from 'int' to 'char' changes value from 2147483392 to 0 [-Wconstant-conversion]
4 | enum E : T { X = 0x7FFFFF00 };
| ^~~~~~~~~~
<source>:4:22: error: enumerator value evaluates to 2147483392, which cannot be narrowed to type 'char' [-Wc++11-narrowing]
2 warnings and 2 errors generated.
Clang erroneously instantiates the enumerators twice in the case of a prior declaration.
As a consequence, the name lookup in the last line of the following example becomes ambiguous.
Compiler output:
Another symptom is that diagnostics during instantiation appear twice in the output if a preceding opaque-enum-declaration exists:
Compiler output:
See here on Compiler Explorer
The text was updated successfully, but these errors were encountered: