public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44920]  New: const rvalue cast results in internal compiler error
@ 2010-07-12 17:50 wsf at fultondesigns dot co dot uk
  2010-07-12 18:21 ` [Bug c++/44920] [C++0x] " redi at gcc dot gnu dot org
  2010-07-12 18:24 ` redi at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: wsf at fultondesigns dot co dot uk @ 2010-07-12 17:50 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2185 bytes --]

>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


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

* [Bug c++/44920] [C++0x] const rvalue cast results in internal compiler error
  2010-07-12 17:50 [Bug c++/44920] New: const rvalue cast results in internal compiler error wsf at fultondesigns dot co dot uk
@ 2010-07-12 18:21 ` redi at gcc dot gnu dot org
  2010-07-12 18:24 ` redi at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-07-12 18:21 UTC (permalink / raw)
  To: gcc-bugs



-- 

redi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.4.3 4.5.0 4.6.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-12 18:21:32
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44920


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

* [Bug c++/44920] [C++0x] const rvalue cast results in internal compiler error
  2010-07-12 17:50 [Bug c++/44920] New: const rvalue cast results in internal compiler error wsf at fultondesigns dot co dot uk
  2010-07-12 18:21 ` [Bug c++/44920] [C++0x] " redi at gcc dot gnu dot org
@ 2010-07-12 18:24 ` redi at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-07-12 18:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from redi at gcc dot gnu dot org  2010-07-12 18:24 -------
Using static_cast<const int&&> also works, the problem is only with C-style
casts


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44920


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

end of thread, other threads:[~2010-07-12 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-12 17:50 [Bug c++/44920] New: const rvalue cast results in internal compiler error wsf at fultondesigns dot co dot uk
2010-07-12 18:21 ` [Bug c++/44920] [C++0x] " redi at gcc dot gnu dot org
2010-07-12 18:24 ` redi at gcc dot gnu dot org

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).