On 6 Nov 2018 01:50:02 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> I wrote the code quoted below.
> I hope one can get my intentions clearly from the code.
>
> What I'd like to ask about is this warning:
>
> main.cpp: In function 'bool is_nontrivial(int, int)':
> main.cpp:20:6: warning: function might be candidate for attribute 'const' [-Wsuggest-attribute=const]
> 20 | bool is_nontrivial( int const i, int const j )
> | ^~~~~~~~~~~~~
>
> Does this warning make sense for a /non-member/ function?
>
> Also feel free to suggest any improvements to my code!
[snip]
This warning seems to be concerned with gcc function attributes rather
than the C and C++ keyword 'const'. If so, it signifies that the
function does not read any global data and only depends on its
arguments:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
It looks as if you have specifically asked for this "warning" (it isn't
really a warning) with the -Wsuggest-attribute=const compiler flag.