lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] gcc '-Wsuggest-attribute=' experiment


From: Greg Chicares
Subject: [lmi] gcc '-Wsuggest-attribute=' experiment
Date: Fri, 5 Jun 2020 22:29:53 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Vadim--I tried building lmi with all the '-Wsuggest-attribute=' flags.
(Inconveniently, syntax like "-Wsuggest-attribute=const,noreturn"
is not supported, so they all have to be spelled out separately.)
After excluding boost, I got only a handful of suggestions. The
question now is whether to do anything about this.

Examples: This MinGW library thing could be "const":

  extern "C" unsigned int _get_output_format(void) {return 1;}

and several functions like this could be "pure":

  bool begins_with(std::string const& s, std::string const& prefix)
  {
      return
             (prefix.size() <= s.size())
          && std::equal(prefix.begin(), prefix.end(), s.begin());
  }

There's a proposal for "[[pure]]" here:
  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0078r0.pdf
but AFAIK the only thing we can do now is add an ugly, nonstandard,
gcc-specific "__attribute__((const|pure))", which might save a few
nanoseconds at the cost of portability. Am I missing anything?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]