Namespaces
Variants
Actions

Talk:cpp/types/underlying type

From cppreference.com

[edit] Non-enumeration type undefined behaviour

This says that using a non-enumeration type is undefined behaviour. This seems odd, can someone clarify if this is correct or not? I thought that it would only be undefined behaviour if the Condition specification in the standard was a "Requires" clause, which it isn't. TartanLlama (talk) 06:54, 2 March 2016 (PST)

The behavior is undefined because it would violate a "shall" clause in the standard. I think the heading "Condition" in table 57 warrants an editorial issue: traits in tables 47-49,51 are the ones that test conditions and so have a "Condition" column, the traits in 50,52-57 are not testing any conditions, and the "Condition" column in table 57 clearly lists requirements on template parameter types. --Cubbi (talk) 09:04, 2 March 2016 (PST)
^ this. In any event, even if violating the "Condition" didn't lead to UB directly, the standard doesn't specify what the behavior is when T is not an enumeration type, so it is still undefined by omission. T. Canens (talk) 00:02, 3 March 2016 (PST)
I raised an editorial issue, although nobody is going to look at it this week because of Jacksonville. --Cubbi (talk) 08:49, 3 March 2016 (PST)
The editorial was accepted, std::underlying_type in the C++17 WP now has a Requires: clause. --Cubbi (talk) 19:04, 22 June 2016 (PDT)