This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in gcc: assignment to non-lvalue
- From: "Andrew Pinski" <pinskia at gmail dot com>
- To: "Michiel de Bondt" <debondt at math dot ru dot nl>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 20 Sep 2007 11:36:22 -0700
- Subject: Re: Bug in gcc: assignment to non-lvalue
- References: <46F2BAF0.8@math.ru.nl>
On 9/20/07, Michiel de Bondt <debondt@math.ru.nl> 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 &value[0] which is considered a rvalue but value[0] is
a lvalue even if a.operator[](0) is an rvalue.
So I think GCC is correct in accepting this code.
Thanks,
Andrew Pinski