public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Scott Snyder <snyder@fnal.gov>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/7828: g++ 3.3: bad non-lvalue error (non_cast_lvalue_or_else)
Date: Thu, 05 Sep 2002 09:26:00 -0000	[thread overview]
Message-ID: <20020905162601.9597.qmail@sources.redhat.com> (raw)

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


             reply	other threads:[~2002-09-05 16:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-05  9:26 Scott Snyder [this message]
  -- 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-09 13:56 Nathan Sidwell
2002-09-04 12:26 Andrew Pinski
2002-09-04 12:06 snyder

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=20020905162601.9597.qmail@sources.redhat.com \
    --to=snyder@fnal.gov \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@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).