This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/78420] [5/6/7 Regression] std::less<T*> is not a total order with -O2 enabled
- From: "jens.maurer at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Jan 2017 22:37:31 +0000
- Subject: [Bug libstdc++/78420] [5/6/7 Regression] std::less<T*> is not a total order with -O2 enabled
- Auto-submitted: auto-generated
- References: <bug-78420-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78420
Jens Maurer <jens.maurer at gmx dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jens.maurer at gmx dot net
--- Comment #16 from Jens Maurer <jens.maurer at gmx dot net> ---
I'd like to point out that there is no prohibition against writing
reinterpret_cast inside a constexpr function. It's just if you call that
function and actually evaluate the reinterpret_cast does the expression turn
into an expression that is not a constant expression.
And there is no requirement that calling a constexpr function with arbitrary
arguments is, in fact, a constant expression in the sense of C++ section 5.20.
There seems to be a tacit understanding that a standard library function marked
as "constexpr" may, in fact, appear in a constant expression if the "obvious"
operations on the arguments are suitable (copy constructor, destructor at
least), but I couldn't find a statement that would make this expectation
explicit.
That means the standard library needs to do its homework to clearly specify
under which circumstances (which argument types) it expects a constexpr
function to be valid in a constant expression. Absent that, simply performing
the reinterpret_cast is the right answer for std::less<T*>, and seems to be
fully conforming with the letter of the current standard.