ToT build problem with nextafterl/nexttowardl (when using ToT GCC)

Martin Sebor msebor@gmail.com
Fri Dec 8 19:54:00 GMT 2017


On 12/08/2017 12:22 PM, Steve Ellcey wrote:
> I have tracked the glibc build problem down to this GCC patch:
>
> +2017-12-07  Martin Sebor  <msebor@redhat.com>
> +
> +	PR c/81544
> +	* attribs.c (empty_attribute_table): Initialize new member of
> (many more lines)
>
> But I am not sure if this is a bug with the patch or an issue with the
> glibc sources where there is an inconsistency in how these two
> functions are declared.

The warning for pure and const declaration conflicts is intended.
When a function is declared with both attributes GCC would (before
the patch) accept both but (possibly by the luck of the draw rather
than by deliberate choice) use the const attribute to decide what
code to emit in the function callers.  When the author of one of
the callers has made assumptions about the function based on its
pure declaration this can lead to a subtle bug if the function is,
n fact, defined to be pure and not const.  This case came up in
the GCC test suite where it exposed a weakness in one of the
tests.

Martin

>
> Steve Ellcey
> sellcey@cavium.com
>
>
> On Fri, 2017-12-08 at 08:51 -0800, Steve Ellcey wrote:
>> Is anyone else seeing this problem when building glibc.  I am using
>> the
>> ToT GCC to build ToT glibc.
>>
>> Steve Ellcey
>> sellcey@cavium.com
>>
>>
>>
>> In file included from ../include/bits/mathcalls.h:1,
>>                  from ../math/math.h:350,
>>                  from ../include/math.h:7,
>>                  from ../sysdeps/aarch64/fpu/s_llround.c:19:
>> ../math/bits/mathcalls.h:259:1: error: ignoring attribute ‘const’ in
>> declaration of a built-in function ‘nextafterl’ because it conflicts
>> with attribute ‘pure’ [-Werror=attributes]
>>  __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y),
>> (__const__));
>>  ^~~~~~~~~~~
>> <built-in>: note: previous declaration here
>> ../math/bits/mathcalls.h:261:1: error: ignoring attribute ‘const’ in
>> declaration of a built-in function ‘nexttowardl’ because it conflicts
>> with attribute ‘pure’ [-Werror=attributes]
>>  __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y),
>> (__const__));
>>  ^~~~~~~~~~~
>> <built-in>: note: previous declaration here



More information about the Libc-alpha mailing list