Re: warn_unused_results

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: warn_unused_results
Date: 2020-11-10 03:34:45
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 09, 2020 at 08:23:31AM +0100, Peter Eisentraut wrote:
> On 2020-11-09 07:56, Michael Paquier wrote:
>> This is accepted by clang, and MSVC has visibly an equivalent for
>> that, as of VS 2012:
>> #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
>> #define pg_nodiscard _Check_return_
>> We don't care about the 1700 condition as we support only >= 1800 on
>> HEAD, and in this case the addition of pg_nodiscard would be required
>> on the definition and the declaration. Should it be added? It is
>> much more invasive than the gcc/clang equivalent though..
> AFAICT from the documentation, this only applies for special "analyze" runs,
> not as a normal compiler warning. Do we have any support for analyze runs
> with MSVC?

You can run them by passing down /p:RunCodeAnalysis=true to MSBFLAGS
when calling the build script. There are more options like
/p:CodeAnalysisRuleSet to define a set of rules. By default the
output is rather noisy though now that I look at it. And having to
add the flag to the definition and the declaration is annoying, so
what you are doing would be enough without MSVC.

>> I am not sure
>> about the addition of repalloc(), as it is quite obvious that one has
>> to use its result. Lists are fine, these are proper to PG internals
>> and beginners tend to be easily confused in the way to use them.
> realloc() is listed in the GCC documentation as the reason this option
> exists, and glibc tags its realloc() with this attribute, so doing the same
> for repalloc() seems sensible.

Good point.

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuro Yamada 2020-11-10 03:38:53 Re: list of extended statistics on psql
Previous Message Kyotaro Horiguchi 2020-11-10 03:26:54 Re: [Patch] Optimize dropping of relation buffers using dlist