[PATCH] C frontend: cast-expressions sometimes retain type qualifiers

Patrick Palka patrick@parcs.ath.cx
Tue Aug 19 14:21:00 GMT 2014


On Mon, Aug 18, 2014 at 2:07 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Sat, 16 Aug 2014, Patrick Palka wrote:
>
>> 2014-08-17  Patrick Palka  ppalka@gcc.gnu.org
>>
>>       * c-typeck.c (build_c_cast): Do a conversion even when the
>>       TYPE_MAIN_VARIANTs are the same.
>>
>> 2014-08-17  Patrick Palka  ppalka@gcc.gnu.org
>>
>>       * gcc.dg/pr13519-1.c: Adjust.
>
> OK, although there's the question of whether typeof and __auto_type should
> remove all qualifiers even from lvalue arguments (at present they do this
> only if the argument is _Atomic-qualified).  (The _Generic implementation
> takes care to remove all qualifiers, although DR#423 has yet to be
> resolved.  But the intended committee direction appears to be along the
> lines you implement - the cast always yields a value of unqualified type.
> We may need to wait for a resolution of the DR to see exactly what's
> needed regarding functions returning qualified types.)

This issue is much hairier than I thought.  But since the patch is in
line with the direction of the committee, and since the patch fixes an
inconsistency with the current implementation, I suppose that's enough
reason to go through with it.  Committed as r214151.  Hope I didn't
inadvertently break anything...

>
> GCC doesn't increase the size of a type when an _Atomic qualifier is
> added, so the presence or absence of qualifiers on the type of an rvalue
> doesn't affect sizeof (although it can affect the GNU extension of
> applying alignof to an expression, I suppose).
>
> --
> Joseph S. Myers
> joseph@codesourcery.com



More information about the Gcc-patches mailing list