public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-09-09 13:56 Nathan Sidwell
  0 siblings, 0 replies; 12+ messages in thread
From: Nathan Sidwell @ 2002-09-09 13:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Nathan Sidwell <nathan@codesourcery.com>
To: snyder@fnal.gov, gcc-gnats@gcc.gnu.org, pcarlini@unitus.it,
   gcc-bugs@gcc.gnu.org, Matt Austern <austern@apple.com>,
   Andrew Pinski
 <pinskia@physics.uc.edu>
Cc: mark@codesourcery.com
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Mon, 09 Sep 2002 21:54:58 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7828
 
 Paolo asked me to look at this and 7858.
 
 <really short version>
 Scott is usually right about c++
 
 <short version>
 Scott's code is well formed, g++ is wrong, Matt's patch probably broke it.
 
 <long version>
 	long (x)
 is an rvalue [5.2.3]/2
 	Foo (const long &)
 can bind to an rvalue [5.2.2]/4, [8.5]/12, [8.5.3]/5 2nd major point
 	'Otherwise the reference shall be to a non-volatile const type' ...
 	'otherwise a temporary of type 'cv1 T1' is created ...'
 
 Matt, as it appears that your patch has broken this, even though it might
 have fixed some bug, could you either fix the latent bug, or revert your patch
 (like the development plan specifies). It'd be neat to add a scott's code as
 a g++ testcase too.
 
 nathan
 


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-11 13:26 Gabriel Dos Reis
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel Dos Reis @ 2002-10-11 13:26 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

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

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Matt Austern <austern@apple.com>
Cc: Pop Sébastian <pop@gauvain.u-strasbg.fr>, austern@gcc.gnu.org,
   gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: 11 Oct 2002 22:24:36 +0200

 Matt Austern <austern@apple.com> writes:
 
 | > Matt did you also fix the bug on the 3.2 branch?
 | 
 | No, TOT only.
 
 Thanks!
 
 -- Gaby


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-11 13:16 Matt Austern
  0 siblings, 0 replies; 12+ messages in thread
From: Matt Austern @ 2002-10-11 13:16 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Matt Austern <austern@apple.com>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: =?ISO-8859-1?Q?Pop_S=E9bastian?= <pop@gauvain.u-strasbg.fr>,
   austern@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Fri, 11 Oct 2002 13:09:53 -0700

 On Friday, October 11, 2002, at 12:58 PM, Gabriel Dos Reis wrote:
 
 > Pop S=E9bastian <pop@gauvain.u-strasbg.fr> writes:
 >
 > | On Wed, Oct 09, 2002 at 01:39:28AM +0200, Gabriel Dos Reis wrote:
 > | > Pop S=E9bastian <pop@gauvain.u-strasbg.fr> writes:
 > | >
 > | > |  I cannot reproduce the error with
 > | > |  gcc version 3.2.1 20020924 (Debian prerelease)
 > | > |
 > | > |  nor with the last cvs:
 > | > |  version gcc 3.3 20021007 (experimental)
 > | >
 > | > Indeed, it was fixed by Matt -- I can't recall off hand when,
 > | > certainly somewhere in September.
 > | >
 > | > -- Gaby
 > |
 > | Maybe the following?
 >
 > Well, it appears that that ChangeLog entry is present on mainline but
 > not on branch.  I've moved it into the appropriate files.
 >
 > Matt did you also fix the bug on the 3.2 branch?
 
 No, TOT only.
 
 			--Matt
 


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-11 13:06 Gabriel Dos Reis
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel Dos Reis @ 2002-10-11 13:06 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

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

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Pop Sébastian <pop@gauvain.u-strasbg.fr>
Cc: austern@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: 11 Oct 2002 21:58:10 +0200

 Pop Sébastian <pop@gauvain.u-strasbg.fr> writes:
 
 | On Wed, Oct 09, 2002 at 01:39:28AM +0200, Gabriel Dos Reis wrote:
 | > Pop Sébastian <pop@gauvain.u-strasbg.fr> writes:
 | > 
 | > |  I cannot reproduce the error with 
 | > |  gcc version 3.2.1 20020924 (Debian prerelease)
 | > |  
 | > |  nor with the last cvs:
 | > |  version gcc 3.3 20021007 (experimental)
 | > 
 | > Indeed, it was fixed by Matt -- I can't recall off hand when,
 | > certainly somewhere in September.
 | > 
 | > -- Gaby
 | 
 | Maybe the following?
 
 Well, it appears that that ChangeLog entry is present on mainline but
 not on branch.  I've moved it into the appropriate files.  
 
 Matt did you also fix the bug on the 3.2 branch?
 
 -- Gaby


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-11 12:59 gdr
  0 siblings, 0 replies; 12+ messages in thread
From: gdr @ 2002-10-11 12:59 UTC (permalink / raw)
  To: austern, gcc-bugs, gcc-prs, snyder

Synopsis: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)

State-Changed-From-To: analyzed->closed
State-Changed-By: gdr
State-Changed-When: Fri Oct 11 12:59:44 2002
State-Changed-Why:
    Fixed on mainline.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7828


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-08 16:56 Pop Sébastian
  0 siblings, 0 replies; 12+ messages in thread
From: Pop Sébastian @ 2002-10-08 16:56 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

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

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: =?iso-8859-1?Q?Pop_S=E9bastian?= <pop@gauvain.u-strasbg.fr>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: austern@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Wed, 9 Oct 2002 01:51:54 +0200

 On Wed, Oct 09, 2002 at 01:39:28AM +0200, Gabriel Dos Reis wrote:
 > Pop Sébastian <pop@gauvain.u-strasbg.fr> writes:
 > 
 > |  I cannot reproduce the error with 
 > |  gcc version 3.2.1 20020924 (Debian prerelease)
 > |  
 > |  nor with the last cvs:
 > |  version gcc 3.3 20021007 (experimental)
 > 
 > Indeed, it was fixed by Matt -- I can't recall off hand when,
 > certainly somewhere in September.
 > 
 > -- Gaby
 
 Maybe the following?
 from gcc/ChangeLog
 
 2002-09-13  Matt Austern  <austern@apple.com>
 
         * cp/cp-tree.h, cp/tree.c: New function non_cast_lvalue_p.
         * cp/call.c: Change call-by-const-reference mechanism to use
         non_cast_lvalue_p when deciding whether the create a temporary.
         We need a temporary when passing, e.g. (long) x by const ref.
         * testsuite/g++.dg/other/constref[12].C: New, regression tests for
         passing a cast expression to a function by const reference.
 
 
 I think this entry should go into cp/ChangeLog ...
 Gaby could you fix that?
 


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-08 16:46 Gabriel Dos Reis
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel Dos Reis @ 2002-10-08 16:46 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

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

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Pop Sébastian <pop@gauvain.u-strasbg.fr>
Cc: austern@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: 09 Oct 2002 01:39:28 +0200

 Pop Sébastian <pop@gauvain.u-strasbg.fr> writes:
 
 |  I cannot reproduce the error with 
 |  gcc version 3.2.1 20020924 (Debian prerelease)
 |  
 |  nor with the last cvs:
 |  version gcc 3.3 20021007 (experimental)
 
 Indeed, it was fixed by Matt -- I can't recall off hand when,
 certainly somewhere in September.
 
 -- Gaby


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-10-08 16:26 Pop Sébastian
  0 siblings, 0 replies; 12+ messages in thread
From: Pop Sébastian @ 2002-10-08 16:26 UTC (permalink / raw)
  To: austern; +Cc: gcc-prs

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: =?iso-8859-1?Q?Pop_S=E9bastian?= <pop@gauvain.u-strasbg.fr>
To: nathan@gcc.gnu.org, austern@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
	gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, snyder@fnal.gov,
	gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Wed, 9 Oct 2002 01:24:56 +0200

 On Fri, Sep 13, 2002 at 04:42:37PM -0000, nathan@gcc.gnu.org wrote:
 > Synopsis: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
 > 
 > Responsible-Changed-From-To: unassigned->austern
 > Responsible-Changed-By: nathan
 > Responsible-Changed-When: Fri Sep 13 09:42:37 2002
 > Responsible-Changed-Why:
 >     patching
 > State-Changed-From-To: open->analyzed
 > State-Changed-By: nathan
 > State-Changed-When: Fri Sep 13 09:42:37 2002
 > State-Changed-Why:
 >     confirmed
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7828
 
 I cannot reproduce the error with 
 gcc version 3.2.1 20020924 (Debian prerelease)
 
 nor with the last cvs:
 version gcc 3.3 20021007 (experimental)
 
 


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-09-13  9:42 nathan
  0 siblings, 0 replies; 12+ messages in thread
From: nathan @ 2002-09-13  9:42 UTC (permalink / raw)
  To: austern, gcc-bugs, gcc-prs, nobody, snyder

Synopsis: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)

Responsible-Changed-From-To: unassigned->austern
Responsible-Changed-By: nathan
Responsible-Changed-When: Fri Sep 13 09:42:37 2002
Responsible-Changed-Why:
    patching
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Fri Sep 13 09:42:37 2002
State-Changed-Why:
    confirmed

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7828


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-09-05  9:26 Scott Snyder
  0 siblings, 0 replies; 12+ messages in thread
From: Scott Snyder @ 2002-09-05  9:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Scott Snyder <snyder@fnal.gov>
To: Andrew Pinski <pinskia@physics.uc.edu>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: 05 Sep 2002 11:18:19 -0500

 >>>>> "Andrew" == Andrew Pinski <pinskia@physics.uc.edu> writes:
     Andrew> One question which libstdc++, because the version 3 is
     Andrew> fine and it compiles just fine with this patch?
 
 It was the head cvs version of libstdc++.
 The original call i had that was giving problems was like this:
 
       std::bind2nd (std::plus<unsigned long>(), 1)
 
 The implementation of bind2nd had the cast inside it.
 Hmm.. maybe it would work if the constant above is explicitly cast to an
 unsigned long --- unfortunately, the disk died yesterday on the machine
 i was testing this on, so i can't test it immediately.
 
     Andrew> Another point, it is invalid code, the problem is that the
     Andrew> casting does makes a variable not a lvalue.
 
 Yeah, but you shouldn't need an lvalue to pass through a const reference,
 right?  I thought that only a non-const ref needed an lvalue; a call
 through a const ref can use a temporary.
 [I can call `void foo(const int&)' with `foo(1)' --- `1' is certainly
 not an lvalue.]  My copy of the standard is in another office,
 so i can't verify what it says right now.
 
     Andrew> The error message is because when you pass an argument
     Andrew> into a function and that argument is a reference,
     Andrew> 	gcc tries to use the unary `&', which means take the
     Andrew> memory location that points to that lvalue.
 
 Yeah, i understand that --- but ideally, an error message should
 refer to the what's in the code the user wrote, not to the result
 of some internal transformation the compiler does.  Thus my
 comment about the message being confusing.
 
 thanks,
 sss


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

* Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-09-04 12:26 Andrew Pinski
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Pinski @ 2002-09-04 12:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7828; it has been noted by GNATS.

From: Andrew Pinski <pinskia@physics.uc.edu>
To: snyder@fnal.gov
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Wed, 4 Sep 2002 15:21:32 -0400

 One question which libstdc++, because the version 3 is fine and it 
 compiles just fine with this patch?
 
 Another point, it is invalid code, the problem is that the casting does 
 makes a variable not a lvalue.
 gcc was accepting the invalid code because no one wanted to fix it 
 until Matt Austern did.
 The error message is because when you pass an argument into a function 
 and that argument is a reference,
 	gcc tries to use the unary `&', which means take the memory location 
 that points to that lvalue.
 
 Thanks,
 Andrew Pinski
 
 PS Also it is not illegal code but invalid code.
 


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

* c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
@ 2002-09-04 12:06 snyder
  0 siblings, 0 replies; 12+ messages in thread
From: snyder @ 2002-09-04 12:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7828
>Category:       c++
>Synopsis:       g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 04 12:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.3 20020903 (experimental)
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: Linux karma 2.4.9-13 #1 Tue Oct 30 20:11:04 EST 2001 i686 unknown
Architecture: i686

	<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../egcs/configure --prefix=/usr/local/egcs --enable-threads=posix --enable-long-long : (reconfigured) 
>Description:

gcc gives an error compiling the code below:

$ g++ -c x.cc
x.cc: In function `binder2nd bind2nd(const int&)':
x.cc:9: error: non-lvalue in unary `&'
$

I believe that this code is legal --- even if it isn't, the error
message is rather confusing (since this code nowhere uses
the unary & operator).  This was derived from the libstdc++
implementation.

Curiously, if i change the bind2nd() function so that it does not
return a value, the error goes away.

It looks like this behavior was introduced by this change:

2002-08-24  Matt Austern  <austern@apple.com>

	* tree.c (lvalue_p_1): Add argument for whether casts of lvalues
	are allowable.
	(real_lvalue_p): Update caller.
	(lvalue_p): Ditto.
	(non_cast_lvalue_or_else): New.
	* tree.h: Declare it.
        * typeck.c (build_unary_op): Use non_cast_lvalue_or_else.


If i disable that change (by changing non_cast_lvalue_or_else()
to lvalue_or_else() in typeck.c), the error goes away.




>How-To-Repeat:

--------------------------------------
struct binder2nd
{
  binder2nd(const long& __y) ;
};

binder2nd
bind2nd(const int& x) 
{
  return binder2nd(long(x));
}
--------------------------------------

>Fix:
	<how to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
>Unformatted:
 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
 SEND-PR: critical     GCC is completely not operational; no work-around known.
 SEND-PR: serious      GCC is not working properly; a work-around is possible.
 SEND-PR: non-critical Report indicates minor problem.
 SEND-PR: medium       The problem should be solved in the next release.
 SEND-PR: low          The problem should be solve in a future release.
 SEND-PR: doc-bug          The documentation is incorrect.
 SEND-PR: accepts-illegal  GCC fails to reject erroneous code.
 SEND-PR: rejects-legal    GCC gives an error message for correct code.
 SEND-PR: wrong-code       The machine code generated by gcc is incorrect.
 SEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
 SEND-PR:                     for correct code
 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
 SEND-PR: pessimizes-code     GCC misses an important optimization opportunity
 SEND-PR: sw-bug              Software bug of some other class than above
 SEND-PR: change-request      A feature in GCC is missing.
 SEND-PR: support             I need help with gcc.


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

end of thread, other threads:[~2002-10-11 20:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-09 13:56 c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else) Nathan Sidwell
  -- strict thread matches above, loose matches on Subject: below --
2002-10-11 13:26 Gabriel Dos Reis
2002-10-11 13:16 Matt Austern
2002-10-11 13:06 Gabriel Dos Reis
2002-10-11 12:59 gdr
2002-10-08 16:56 Pop Sébastian
2002-10-08 16:46 Gabriel Dos Reis
2002-10-08 16:26 Pop Sébastian
2002-09-13  9:42 nathan
2002-09-05  9:26 Scott Snyder
2002-09-04 12:26 Andrew Pinski
2002-09-04 12:06 snyder

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