[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unused parameter warnings
From: |
Marc Nieper-Wißkirchen |
Subject: |
Re: Unused parameter warnings |
Date: |
Wed, 7 Oct 2020 08:07:39 +0200 |
Am Di., 6. Okt. 2020 um 23:06 Uhr schrieb Bruno Haible <bruno@clisp.org>:
> Marc Nieper-Wißkirchen wrote:
> > In file included from lib/gl_linked_list.c:29:
> > lib/gl_linked_list.c: In function 'gl_linked_iterator_from_to':
> > lib/gl_anylinked_list2.h:938:1: error: function might be candidate for
> > attribute 'pure' if it is known to return normally
> > [-Werror=suggest-attribute=pure]
> > 938 | gl_linked_iterator_from_to (gl_list_t list,
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> But no such warning in line 920? Makes no sense to me.
The function is static and will be inlined everywhere so the static
analyzer (in the relevant optimizing levels) doesn't seem to get to
the point where it has to/can check whether the function is pure or
not.
> And a function that may invoke abort () does "affect observable state".
This description of the a pure function does not seem to be accurate.
When a function calls another function like abort that is marked with
_Noreturn in a pure context, for the compiler the function can still
be pure (but not const). It can eliminate a second call to the
function with the same parameters. I am pretty sure that the warning
of GCC in line 938 is correct. (It has to be conservative about this
warning because you cannot mark a funciton non-pure.)
(That GCC understands about _Noreturn in a pure context is important
as otherwise the assert debugging facility becomes less usable.)
- Unused parameter warnings, Marc Nieper-Wißkirchen, 2020/10/04
- Re: Unused parameter warnings, Bruno Haible, 2020/10/04
- Re: Unused parameter warnings, Marc Nieper-Wißkirchen, 2020/10/06
- Re: Unused parameter warnings, Bruno Haible, 2020/10/06
- Re: Unused parameter warnings,
Marc Nieper-Wißkirchen <=
- Re: Unused parameter warnings, Bruno Haible, 2020/10/10
- Re: Unused parameter warnings, Marc Nieper-Wißkirchen, 2020/10/10
- Re: Unused parameter warnings, Bruno Haible, 2020/10/10
- Re: Unused parameter warnings, Marc Nieper-Wißkirchen, 2020/10/10
- Re: Unused parameter warnings, Paul Eggert, 2020/10/10
- Re: Unused parameter warnings, Bruno Haible, 2020/10/10
- Re: Unused parameter warnings, Paul Eggert, 2020/10/11
- Re: Unused parameter warnings, Jeffrey Walton, 2020/10/11
- Re: 'const' function attribute, Bruno Haible, 2020/10/13
- Re: 'const' function attribute, Paul Eggert, 2020/10/14