public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14211] New: missing lvalue check ?
@ 2004-02-19 15:06 d dot binderman at virgin dot net
  2004-02-20 21:30 ` [Bug c++/14211] " bangerth at dealii dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: d dot binderman at virgin dot net @ 2004-02-19 15:06 UTC (permalink / raw)
  To: gcc-bugs

// Given the following C++ code

void f( char * str)
{

	char * & m = const_cast<char *>( str);
}

/*
then g++ 332 says not a lot.

[dcb@localhost src]$ ~/gnu/gcc332/results/bin/g++ -c -g -O2 -Wall -ansi
-pedantic cc.cc
cc.cc: In function `void f(char*)':
cc.cc:7: warning: unused variable `char*&m'
[dcb@localhost src]$

But Intel C++ 8.0 says

[dcb@localhost src]$ icc cc.cc
cc.cc(7): error: initial value of reference to non-const must be an lvalue
        char * & m = const_cast<char *>( str);
                     ^

compilation aborted for cc.cc (code 2)
[dcb@localhost src]$

One compiler must be wrong. 

*/

-- 
           Summary: missing lvalue check ?
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot binderman at virgin dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: linux/i386


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


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

* [Bug c++/14211] missing lvalue check ?
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
@ 2004-02-20 21:30 ` bangerth at dealii dot org
  2004-02-23  1:42 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast should return lvalues giovannibajo at libero dot it
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-20 21:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-20 21:30 -------
5.2.11/1 clearly states that the result of a const_cast<T> is of type T. 
In your case, it is a char*, so it is not an lvalue. Thus, gcc must 
be wrong. Note also 5.2.11/4. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-20 21:30:30
               date|                            |


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast should return lvalues
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
  2004-02-20 21:30 ` [Bug c++/14211] " bangerth at dealii dot org
@ 2004-02-23  1:42 ` giovannibajo at libero dot it
  2004-04-28  2:05 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-02-23  1:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-02-23 01:42 -------
Agreed, GCC is wrong here.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
      Known to fail|                            |3.3.3 3.4.0 3.5.0
      Known to work|                            |3.2.3
            Summary|missing lvalue check ?      |[3.3/3.4/3.5 Regression]
                   |                            |const_cast should return
                   |                            |lvalues


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
  2004-02-20 21:30 ` [Bug c++/14211] " bangerth at dealii dot org
  2004-02-23  1:42 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast should return lvalues giovannibajo at libero dot it
@ 2004-04-28  2:05 ` pinskia at gcc dot gnu dot org
  2004-06-06  3:36 ` giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-28  2:05 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3/3.4/3.5 Regression]    |[3.3/3.4/3.5 Regression]
                   |const_cast should return    |const_cast returns lvalue
                   |lvalues                     |but should be rvalue
   Target Milestone|---                         |3.3.4


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (2 preceding siblings ...)
  2004-04-28  2:05 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue pinskia at gcc dot gnu dot org
@ 2004-06-06  3:36 ` giovannibajo at libero dot it
  2004-06-09 19:11 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-06-06  3:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-06-06 03:36 -------
Retargeting to 3.4.1, being a regression on that release branch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdr at gcc dot gnu dot org
   Target Milestone|3.3.4                       |3.4.1


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (3 preceding siblings ...)
  2004-06-06  3:36 ` giovannibajo at libero dot it
@ 2004-06-09 19:11 ` mmitchel at gcc dot gnu dot org
  2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-09 19:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-09 19:11 -------
Working on a fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (4 preceding siblings ...)
  2004-06-09 19:11 ` mmitchel at gcc dot gnu dot org
@ 2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
  2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-10 14:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-10 14:26 -------
Subject: Bug 14211

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-06-10 14:26:23

Modified files:
	gcc/cp         : ChangeLog parser.c pt.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/conversion: const1.C reinterpret1.C 
	gcc/testsuite/g++.dg/template: enum2.C error13.C 

Log message:
	PR c++/15227
	* parser.c (cp_parser_direct_declarator): Robustify.
	
	PR c++/15877
	* pt.c (tsubst_copy): Use decl_constant_value on enumeration
	constants in non-dependent contexts.
	
	PR c++/14211
	PR c++/15076
	* typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when
	necessary.
	
	PR c++/14211
	* g++.dg/conversion/const1.C: New test.
	
	PR c++/15076
	* g++.dg/conversion/reinterpret1.C: New test.
	
	PR c++/15877
	* g++.dg/template/enum2.C: New test.
	
	PR c++/15227
	* g++.dg/template/error13.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4089&r2=1.4090
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.202&r2=1.203
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.860&r2=1.861
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.548&r2=1.549
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/const1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/reinterpret1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (5 preceding siblings ...)
  2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
@ 2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
  2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
  2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-10 14:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-10 14:26 -------
Subject: Bug 14211

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-06-10 14:26:50

Modified files:
	gcc/cp         : ChangeLog parser.c pt.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/conversion: const1.C reinterpret1.C 
	gcc/testsuite/g++.dg/template: enum2.C error13.C 

Log message:
	PR c++/15227
	* parser.c (cp_parser_direct_declarator): Robustify.
	
	PR c++/15877
	* pt.c (tsubst_copy): Use decl_constant_value on enumeration
	constants in non-dependent contexts.
	
	PR c++/14211
	PR c++/15076
	* typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when
	necessary.
	
	PR c++/14211
	* g++.dg/conversion/const1.C: New test.
	
	PR c++/15076
	* g++.dg/conversion/reinterpret1.C: New test.
	
	PR c++/15877
	* g++.dg/template/enum2.C: New test.
	
	PR c++/15227
	* g++.dg/template/error13.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.119&r2=1.3892.2.120
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.32&r2=1.157.2.33
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.29&r2=1.816.2.30
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.19&r2=1.519.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/const1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/reinterpret1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error13.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (6 preceding siblings ...)
  2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
@ 2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
  2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-10 14:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-10 14:30 -------
Fixed in GCC 3.4.1.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue
  2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
                   ` (7 preceding siblings ...)
  2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
@ 2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-10 14:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-10 14:30 -------
*** Bug 15076 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |niemayer at isg dot de


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


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

end of thread, other threads:[~2004-06-10 14:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-19 15:06 [Bug c++/14211] New: missing lvalue check ? d dot binderman at virgin dot net
2004-02-20 21:30 ` [Bug c++/14211] " bangerth at dealii dot org
2004-02-23  1:42 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast should return lvalues giovannibajo at libero dot it
2004-04-28  2:05 ` [Bug c++/14211] [3.3/3.4/3.5 Regression] const_cast returns lvalue but should be rvalue pinskia at gcc dot gnu dot org
2004-06-06  3:36 ` giovannibajo at libero dot it
2004-06-09 19:11 ` mmitchel at gcc dot gnu dot org
2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
2004-06-10 14:30 ` mmitchel at gcc dot gnu dot org
2004-06-10 14:30 ` mmitchel 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).