public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114410] New: compiler issue in reference_binding when using rvalue reference to member of const object
@ 2024-03-21  8:54 cvoica at gmail dot com
  2024-03-21  9:05 ` [Bug c++/114410] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: cvoica at gmail dot com @ 2024-03-21  8:54 UTC (permalink / raw)
  To: gcc-bugs

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;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-21 11:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21  8:54 [Bug c++/114410] New: compiler issue in reference_binding when using rvalue reference to member of const object cvoica at gmail dot com
2024-03-21  9:05 ` [Bug c++/114410] " pinskia at gcc dot gnu.org
2024-03-21  9:07 ` pinskia at gcc dot gnu.org
2024-03-21  9:18 ` cvoica at gmail dot com
2024-03-21  9:26 ` cvoica at gmail dot com
2024-03-21 10:25 ` redi at gcc dot gnu.org
2024-03-21 10:45 ` cvoica at gmail dot com
2024-03-21 11:43 ` cvoica at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).