public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: snyder@fnal.gov
To: gcc-gnats@gcc.gnu.org
Subject: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Wed, 04 Sep 2002 12:06:00 -0000	[thread overview]
Message-ID: <200209041857.NAA82920@d0sgibnl1.fnal.gov> (raw)


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


             reply	other threads:[~2002-09-04 19:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-04 12:06 snyder [this message]
2002-09-04 12:26 Andrew Pinski
2002-09-05  9:26 Scott Snyder
2002-09-09 13:56 Nathan Sidwell
2002-09-13  9:42 nathan
2002-10-08 16:26 Pop Sébastian
2002-10-08 16:46 Gabriel Dos Reis
2002-10-08 16:56 Pop Sébastian
2002-10-11 12:59 gdr
2002-10-11 13:06 Gabriel Dos Reis
2002-10-11 13:16 Matt Austern
2002-10-11 13:26 Gabriel Dos Reis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200209041857.NAA82920@d0sgibnl1.fnal.gov \
    --to=snyder@fnal.gov \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).