Re: Bug in gcc: assignment to non-lvalue

2007-09-24 Thread Jonathan Wakely
On 24/09/2007, Jonathan Adamczewski <[EMAIL PROTECTED]> wrote: > > What about something like the following? > > struct proxy { > T& t; > proxy(T& t_) : t(t_) {} > proxy& operator=(const T& r) { foo(t, r); return *this; } > }; > > struct B { proxy get() { return proxy(bar); } }; > > int

Re: Bug in gcc: assignment to non-lvalue

2007-09-23 Thread Jonathan Adamczewski
Jonathan Wakely wrote: I believe Andrew's right and the strcpy case is valid, but you do have a point. I think this should be rejected: struct A { int i; }; struct B { A get() { return A(); } }; int main () { B b; b.get().i = 0; // int& error = b.get().i; } What about somethin

Re: Bug in gcc: assignment to non-lvalue

2007-09-22 Thread Jonathan Wakely
On 21/09/2007, Michiel de Bondt <[EMAIL PROTECTED]> wrote: > Using strings to show my point was not a good idea. You can add a field > "int number" to the struct and perform similar operations (with = > instead of strcpy). I believe Andrew's right and the strcpy case is valid, but you do have a po

Re: Bug in gcc: assignment to non-lvalue

2007-09-21 Thread Aaron W. LaFramboise
Michiel de Bondt wrote: Using strings to show my point was not a good idea. You can add a field "int number" to the struct and perform similar operations (with = instead of strcpy). But even with strings, gcc should give an error like: "strcpy(const char*, const char*) does not exists". In c

Re: Bug in gcc: assignment to non-lvalue

2007-09-20 Thread Michiel de Bondt
Using strings to show my point was not a good idea. You can add a field "int number" to the struct and perform similar operations (with = instead of strcpy). But even with strings, gcc should give an error like: "strcpy(const char*, const char*) does not exists". In case of a "typedef char st

Re: Bug in gcc: assignment to non-lvalue

2007-09-20 Thread Andrew Pinski
On 9/20/07, Michiel de Bondt <[EMAIL PROTECTED]> wrote: > struct string100 { char value[100]; }; > strcpy (a[0].value, "Non-lvalue assignment."); // illegal So you basically have: a.operator[](0).value Where value ia an array, I cannot remember the specific rules here but value decays to &valu

Bug in gcc: assignment to non-lvalue

2007-09-20 Thread Michiel de Bondt
Hello all, I think the gcc compiler should not accept assignments to non-lvalues. gcc does this however, but does not execute the assignment (probably the assignment is executed on a copy, but that copy is entirely floating). Here is my code: #include #include #include template class SuperAr