https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104348
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is already fixed on the gcc-10 branch and in 11.1.0
Reduced to compile-time test:
#include<string_view>
#include<algorithm>
class Test
{
public:
//for some reason, bug don't appear if std::string_view not wrapped in
another class
class Value
{
public:
constexpr Value(const char*str):data(str){}
constexpr bool operator<(const Value&value)const{return
data<value.data;}
std::string_view data;
};
constexpr Test()
{
//no bug if std::sort used
//std::sort(array,array+8);
std::make_heap(array,array+8);
std::sort_heap(array,array+8);
}
Value array[8]={"1","2","3","4","5","6","7","8"};
};
//Bug. Product 17256348 instead of 12345678
static constexpr Test test;
static_assert( test.array[1].data[0] == '2' );
Fixed by r11-8056:
PR c++/99859
* constexpr.c (addr_of_non_const_var): New function.
(cxx_bind_parameters_in_call): Set *non_constant_args to true
even if cp_walk_tree on arg with addr_of_non_const_var callback
returns true.
That was already backported as r10-9722
*** This bug has been marked as a duplicate of bug 99859 ***