public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue
@ 2005-05-04 18:31 benh at bwsint dot com
  2005-05-04 18:34 ` [Bug c++/21386] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: benh at bwsint dot com @ 2005-05-04 18:31 UTC (permalink / raw)
  To: gcc-bugs

g++ reports an error where a program attempts to take the address of an rvalue
of built-in type, but merely warns where it takes the address of an rvalue of
user-defined type:

$ cat test.cc
int i() { return 0; }
class A {};
A a() { return A(); }
int main()
{
    int * pi = &i();
    A * pa = &a();
}
$ g++-3.4 test.cc
test.cc: In function `int main()':
test.cc:6: error: non-lvalue in unary `&'
test.cc:7: warning: taking address of temporary

The first error message is also odd; "non-lvalue" is C terminology that is
rarely used in relation to C++.

I would expect an attempt to take the address of an rvalue of any type to result
in an error; it's banned by the standard and I can't think of any useful
semantics for it if it is allowed.

-- 
           Summary: Inconsistent diagnostics for taking address of rvalue
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: benh at bwsint dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
  2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
@ 2005-05-04 18:34 ` pinskia at gcc dot gnu dot org
  2005-05-05  5:17 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-04 18:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-04 18:34 -------
(In reply to comment #0)
> The first error message is also odd; "non-lvalue" is C terminology that is
> rarely used in relation to C++.

That is wrong because the standard actually uses lvalue and rvalue all the time.

-- 


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
  2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
  2005-05-04 18:34 ` [Bug c++/21386] " pinskia at gcc dot gnu dot org
@ 2005-05-05  5:17 ` pinskia at gcc dot gnu dot org
  2005-05-06 16:05 ` benh at bwsint dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-05  5:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-05 05:17 -------
Note ICC causes the same thing in terms of error vs warning.

-- 


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
  2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
  2005-05-04 18:34 ` [Bug c++/21386] " pinskia at gcc dot gnu dot org
  2005-05-05  5:17 ` pinskia at gcc dot gnu dot org
@ 2005-05-06 16:05 ` benh at bwsint dot com
  2005-05-06 16:10 ` benh at bwsint dot com
  2005-05-17 16:28 ` bangerth at dealii dot org
  4 siblings, 0 replies; 7+ messages in thread
From: benh at bwsint dot com @ 2005-05-06 16:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From benh at bwsint dot com  2005-05-06 16:04 -------
(In reply to comment #1)
> (In reply to comment #0)
> > The first error message is also odd; "non-lvalue" is C terminology that is
> > rarely used in relation to C++.
> 
> That is wrong because the standard actually uses lvalue and rvalue all the time.

Right, and it uses "rvalue" rather than "non-lvalue". So far as I can see, all
rvalues of user-defined type are temporaries, so there would be no loss of
precision in changing "temporary" to "rvalue" as well.


-- 


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
  2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
                   ` (2 preceding siblings ...)
  2005-05-06 16:05 ` benh at bwsint dot com
@ 2005-05-06 16:10 ` benh at bwsint dot com
  2005-05-17 16:28 ` bangerth at dealii dot org
  4 siblings, 0 replies; 7+ messages in thread
From: benh at bwsint dot com @ 2005-05-06 16:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From benh at bwsint dot com  2005-05-06 16:10 -------
(In reply to comment #2)
> Note ICC causes the same thing in terms of error vs warning.

That'll be because ICC emulates gcc behaviour...


-- 


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
  2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
                   ` (3 preceding siblings ...)
  2005-05-06 16:10 ` benh at bwsint dot com
@ 2005-05-17 16:28 ` bangerth at dealii dot org
  4 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2005-05-17 16:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-05-17 16:27 -------
Discussing the exact wording is nitpicking. The problem is real so let's 
confirm this PR. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-05-17 16:27:11
               date|                            |


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


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

* [Bug c++/21386] Inconsistent diagnostics for taking address of rvalue
       [not found] <bug-21386-4@http.gcc.gnu.org/bugzilla/>
@ 2012-02-02 13:34 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-02 13:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-02 13:33:59 UTC ---
4.6 gives:

x.cc: In function 'int main()':
x.cc:6:19: error: lvalue required as unary '&' operand
x.cc:7:17: error: taking address of temporary [-fpermissive]


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

end of thread, other threads:[~2012-02-02 13:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-04 18:31 [Bug c++/21386] New: Inconsistent diagnostics for taking address of rvalue benh at bwsint dot com
2005-05-04 18:34 ` [Bug c++/21386] " pinskia at gcc dot gnu dot org
2005-05-05  5:17 ` pinskia at gcc dot gnu dot org
2005-05-06 16:05 ` benh at bwsint dot com
2005-05-06 16:10 ` benh at bwsint dot com
2005-05-17 16:28 ` bangerth at dealii dot org
     [not found] <bug-21386-4@http.gcc.gnu.org/bugzilla/>
2012-02-02 13:34 ` redi at gcc dot gnu.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).