>Submitter-Id: net
>Originator: William S Fulton
>Organization: <organization of PR author (multiple lines)>
>Confidential: no
>Synopsis: const rvalue cast results in internal compiler error
>Severity: serious
>Priority: medium
>Category: <choose from the top of this file (one line)>
>Class: ice-on-legal-code
>Release: gcc-4.5 (GCC) 4.5.0
>Environment:
System: Linux caracal 2.6.27-16-generic #1 SMP Tue Dec 1 17:56:54 UTC 2009 i686
GNU/Linux
<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --program-suffix=-4.5
>Description:
A rvalue cast involving a const gives internal compiler error
>How-To-Repeat:
$ g++-4.5 -E -std=gnu++0x runme.cxx
# 1 "runme.cxx"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "runme.cxx"
class A {
public:
void set(const int &&a) {
_a = a;
}
private:
int _a;
};
template<typename T> T Copy(const T& t) {
return T(t);
};
void doit() {
A a;
A *arg1 = (A *) &a;
int arg2 = 0 ;
(arg1)->set((const int&&)Copy<const int>(arg2));
}
int main ()
{
doit();
return 0;
}
$ g++-4.5 -std=gnu++0x runme.cxx
runme.cxx: In function void doit():
runme.cxx:22:48: internal compiler error: in cp_build_c_cast, at
cp/typeck.c:6308
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
>Fix:
Remove the cast replacing:
(arg1)->set((const int&&)Copy<const int>(arg2));
with:
(arg1)->set(Copy<const int>(arg2));
Note (fix 2): if 'const int' is replaced with 'int' everywhere, everything
works fine.
--
Summary: const rvalue cast results in internal compiler error
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wsf at fultondesigns dot co dot uk
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44920