This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: generalized lvalues
Matt Austern <austern@apple.com> wrote:
> I take the pessimistic view that there are lots
> of programmers who have no idea what the language definition is for
> the language they're using, but just throw code at the compiler until
> the compiler produces an executable that seems to work.
That is surely true.
> So I think
> there may be some people who are using the cast-as-lvalue
> extension even if they don't know what a cast or an lvalue is.
Sure. Lately, I have been asked help to upgrade an existing C++ codebase from
2.95 to 3.4. I addressed the guys (which have no advanced C++ knowledge at all,
let alone standard terms understanding) to changes.html for that release, and
that allowed them to fix all the problems *but* this line:
int x;
[....]
(short)x = a;
What they actually wanted to do is "x = (short)a", but they could not come up
with this trivial fix by themselves. Notice that changes.html mention this
issue but does not suggest how to fix this bug (not even in such a trivial
case). The other half of the problem is that our error message is:
lvalue.cc:5: error: non-lvalue in assignment
which requires knowledge of what a lvalue is. And whatever we may think, they
do not teach that in C++ 101.
If you want to pursue a small task to ease the removal of this feature, I
suggest you to prepare a patch against the C/C++ frontend to simplify the text
of the diagnostic, and one against changes.html to simplify the wording (maybe
explaining in 3 words what a lvalue is) and suggesting some possible solution.
Giovanni Bajo