This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ extension "cast-as-lvalues": time to deprecate?


On Friday, May 9, 2003, at 10:15 AM, Joe Buck wrote:

On Fri, May 09, 2003 at 08:54:25AM +0200, Gabriel Dos Reis wrote:
This extension is an examplar of extensions that were not given enough
thought and are causing much more trouble than they do useful things.
This extension in particular is not needed nor useful in C++ because
they are far better alternatives.  It is pointless.
It should simply be removed.

As it has already been deprecated, I agree that it should be removed.
Because of bad interactions with references, its presence can cause severe
problems; in particular, it can cause the wrong overloaded function in a
conforming C++ program to be chosen. Since it's likely that a non-const
function will be chosen instead of a const function, severe things can
happen, like code attempting to change a literal in a read-only section,
giving a program crash.

We said it was deprecated in the documentation, but we never enforced that with a warning. I think the schedule for removal will have to look something like this: - Next release: put in a warning for this extension, and allow users to turn it off with a switch. - The release after that: don't allow users to turn the warning off. - Finally, in the next release: remove it entirely.

I could imagine doing this over the course of two releases instead
of three, but two is the absolute minimum.

I agree, for what it's worth, that this extension should go.  It was
poorly thought out, and we never specified how it was supposed to
interact with other language features.  (We've seen two different
problems with it in the Apple code base.)  Doing language extension
correctly takes a lot of work.

--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]