generalized lvalues -- patch outline

Steve Naroff snaroff@apple.com
Tue Nov 23 15:50:00 GMT 2004


On Nov 23, 2004, at 7:06 AM, Andrew Pinski wrote:

>
> On Nov 23, 2004, at 9:56 AM, Michael Matz wrote:
>
>> Hi,Practically speaking 4.0 is currently strictly less usefull in some
>> aspects for the average C programmer.
>
> The average C programmer would not have thought to use this extension
> unless they just decided one day to try it or they actually read the
> gcc documentation (which I know almost nobody does).

I believe this is true, however some programmers end up using gcc 
extensions without knowing they are extensions (e.g. variable length 
arrays, non-constant initializers, etc.). This happens for the same 
reason you cite - many programmers don't study the language standard 
(or compile with the strict ANSI modes). Since many of the extensions 
don't add any new syntax, it is easy to become dependent on these 
features without realizing it.

Like you, I'd love to see this feature removed. Unfortunately, I am 
concerned about breaking code. Language features are like API's...they 
are part of the contract we make with our developers. Years ago, I felt 
inclined to disable all gcc extensions for Apple's compiler. I didn't 
do it because I knew there would be fallout. Unfortunately, this is a 
great example of why the thought crossed my mind...

btw...I contacted Andreas Hommel (author of the CW C++ front-end). He 
added generalized lvalue support for gcc compatibility (though they 
appear to get the right answer for the cases I've been forwarded, 
whereas gcc doesn't). He has no affinity for the feature and would 
consider removing it...he has the same concern as I just 
described...breaking code.

> (We keep getting
> bug reports about invalid C++ which explicitly added to the changes
> page and in the bug section of the documentation but those people
> seems not bothered to read those places.)
>
> if you had the following:
>
> ((int*)a)++;
>
> the better idea would be:
>
> char *a1 = (char*)a;
> a1 += sizeof(int)/sizeof(char);
> a = (typeof(a))(a1);
>
> -- Pinski
>



More information about the Gcc mailing list