From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15821 invoked by alias); 22 Apr 2004 20:21:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 15812 invoked by uid 48); 22 Apr 2004 20:21:04 -0000 Date: Thu, 22 Apr 2004 21:06:00 -0000 Message-ID: <20040422202104.15811.qmail@sources.redhat.com> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040422183522.15076.niemayer@isg.de> References: <20040422183522.15076.niemayer@isg.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/15076] [3.3/3.4/3.5 regression] result of reinterpret_cast is an lvalue X-Bugzilla-Reason: CC X-SW-Source: 2004-04/txt/msg02052.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2004-04-22 20:20 ------- Indeed, your code should not be accepted, since you can't bind an rvalue to a non-const reference (this is something that gcc supported as an extension in the past, but it was deemed Evil). Here's something smaller: ----------------- struct Y { Y(int &); }; int v; Y y1(reinterpret_cast(v)); Y y2((int)v); ---------------- gcc3.4 only rejects the second line, though I believe it should also do so for the first one (like icc does): g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc:5: error: no matching function for call to `Y::Y(int)' x.cc:1: note: candidates are: Y::Y(const Y&) x.cc:1: note: Y::Y(int&) g/x> icc -c -Xc -ansi x.cc x.cc(4): error: no instance of constructor "Y::Y" matches the argument list argument types are: (int) Y y1(reinterpret_cast(v)); ^ x.cc(5): error: no instance of constructor "Y::Y" matches the argument list argument types are: (int) Y y2((int)v); ^ compilation aborted for x.cc (code 2) BTW, gcc2.95 had this error message, which is somewhat clearer: g/x> /home/bangerth/bin/gcc-2.95.3/bin/c++ -c x.cc x.cc: In function `void __static_initialization_and_destruction_0(int, int)': x.cc:4: initialization of non-const reference type `int &' x.cc:4: from rvalue of type `int' x.cc:1: in passing argument 1 of `Y::Y(int &)' x.cc:5: initialization of non-const reference type `int &' x.cc:5: from rvalue of type `int' x.cc:1: in passing argument 1 of `Y::Y(int &)' (This error message regression is tracked somewhere else, though.) However, note that 2.95 rejected both calls, as does 3.2.3. That we accept the first one is a regression introduced in 3.3: g/x> /home/bangerth/bin/gcc-3.2.3/bin/c++ -c x.cc x.cc: In function `void __static_initialization_and_destruction_0(int, int)': x.cc:4: no matching function for call to `Y::Y(int)' x.cc:1: candidates are: Y::Y(const Y&) x.cc:1: Y::Y(int&) x.cc:5: no matching function for call to `Y::Y(int)' x.cc:1: candidates are: Y::Y(const Y&) x.cc:1: Y::Y(int&) g/x> g/x> g/x> /home/bangerth/bin/gcc-3.3*/bin/c++ -c x.cc x.cc:5: error: no matching function for call to `Y::Y(int)' x.cc:1: error: candidates are: Y::Y(const Y&) x.cc:1: error: Y::Y(int&) W. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Known to fail| |3.3.4 3.4.0 3.5.0 Known to work| |2.95.3 3.2.3 Last reconfirmed|0000-00-00 00:00:00 |2004-04-22 20:21:02 date| | Summary|cast to void * of parameter |[3.3/3.4/3.5 regression] |in call to template |result of reinterpret_cast |constructor causes |is an lvalue |compilation error | Target Milestone|--- |3.3.4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15076