public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38870]  New: G++ allows modification of data members for a non lvalue object
@ 2009-01-16 12:04 stefan dot constantin at gmail dot com
  2009-01-16 12:11 ` [Bug c++/38870] " stefan dot constantin at gmail dot com
  2009-01-16 20:33 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: stefan dot constantin at gmail dot com @ 2009-01-16 12:04 UTC (permalink / raw)
  To: gcc-bugs

taking into account the following program
-------------------------------------------------
class tester {
public:
        int i;
        void foo() {}
};

int main()
{
        tester().foo();
        tester().i = 10;
        return 0;
}
-------------------------------------------------

The C++ standard (under 3.10.2 lvalues and rvalues) specifies that the result
from tester() is not an lvalue but implementations can invoke member functions
on the rvalue.
In this case tester().foo() is permitted, which is ok, but tester().i =
something should not be permitted since the implementation is only allowed to
invoke member functions.

Thank you,

Stefan Constantin


-- 
           Summary: G++ allows modification of data members for a non lvalue
                    object
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stefan dot constantin at gmail dot com
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


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


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

* [Bug c++/38870] G++ allows modification of data members for a non lvalue object
  2009-01-16 12:04 [Bug c++/38870] New: G++ allows modification of data members for a non lvalue object stefan dot constantin at gmail dot com
@ 2009-01-16 12:11 ` stefan dot constantin at gmail dot com
  2009-01-16 20:33 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: stefan dot constantin at gmail dot com @ 2009-01-16 12:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from stefan dot constantin at gmail dot com  2009-01-16 12:07 -------
Sorry for not mentioning this earlier, 

the sample program provide compiles without error or warning with

g++ -Wall. 
I expected the compiler to error on the line "tester().i = 10;" because such a
construct requires an lvalue.

Thanks


-- 


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


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

* [Bug c++/38870] G++ allows modification of data members for a non lvalue object
  2009-01-16 12:04 [Bug c++/38870] New: G++ allows modification of data members for a non lvalue object stefan dot constantin at gmail dot com
  2009-01-16 12:11 ` [Bug c++/38870] " stefan dot constantin at gmail dot com
@ 2009-01-16 20:33 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-16 20:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-01-16 20:33 -------
Except really it is 5.2.5 that causes this to be invalid code.  Well the C++
standard as written in 1998, it is valid but there is a defect report against
it and it fixed this code to be invalid.

*** This bug has been marked as a duplicate of 15218 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2009-01-16 20:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-16 12:04 [Bug c++/38870] New: G++ allows modification of data members for a non lvalue object stefan dot constantin at gmail dot com
2009-01-16 12:11 ` [Bug c++/38870] " stefan dot constantin at gmail dot com
2009-01-16 20:33 ` pinskia 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).