[Bug c++/38870] New: G++ allows modification of data members for a non lvalue object
stefan dot constantin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jan 16 12:04:00 GMT 2009
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
More information about the Gcc-bugs
mailing list