-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Description
#include <limits>
bool bool_trap() { return std::numeric_limits<bool>::traps; }
bool char_trap() { return std::numeric_limits<char>::traps; }
bool int_trap() { return std::numeric_limits<int>::traps; }Result: false, true, true https://godbolt.org/z/q94jhqjsT
Expected: true, true, true. true/false traps just as much as 1/0 (if not optimized out - it is UB).
You can argue that division by false promotes to int, therefore it's not an operation on bool that traps, but if so, char is wrong.
Alternatively, one can argue that the entire traps member should be deprecated and removed, since every trapping operation is UB, and reasoning about the behavior of undefined behavior makes no sense.
See also microsoft/STL#5816, where MS-STL asks what traps should do.
Metadata
Metadata
Assignees
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.