[Bug c++/114410] New: compiler issue in reference_binding when using rvalue reference to member of const object
cvoica at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Mar 21 08:54:04 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114410
Bug ID: 114410
Summary: compiler issue in reference_binding when using rvalue
reference to member of const object
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cvoica at gmail dot com
Target Milestone: ---
The issue "internal compiler error: in reference_binding, at cp/call.cc:2020"
is visible when compiling this program
#include<iostream>
#include<string>
template<typename T>
class Holder{
typedef T value_type;
value_type m_v;
public:
Holder(const value_type& v):m_v(v){}
operator const value_type() const{return m_v;}
operator value_type(){return m_v;}
// operator const value_type&() const{return m_v;}
// operator value_type&(){return m_v;}
};
struct A {
Holder<std::string> m_i;
A(const std::string& i):m_i(i){}
};
void bad_const_access(const A* a){
std::cout << (std::string&)a->m_i << std::endl; //crash in gcc-13 but OK in
gcc-12
}
void correct_const_access(const A* a){
std::cout << (const std::string&)a->m_i << std::endl;
}
int main(){
const A a("test");
bad_const_access(&a);
correct_const_access(&a);
return 0;
}
More information about the Gcc-bugs
mailing list