pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Windows warnings from VS 2017
Date: Wed, 20 Sep 2017 19:54:54 -0400
Message-ID: <8649.1505951694@sss.pgh.pa.us> (raw)
In-Reply-To: <f6488a36-4702-6d50-9fb4-fee10bb49497@2ndQuadrant.com>
References: <f6488a36-4702-6d50-9fb4-fee10bb49497@2ndQuadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> It's also warning that it will copy 16 bytes to a 13 byte structure at
> lines 518, 1293 and 1294 of src/backend/commands/dbcommands.c. I haven't
> seen any ill effects of this so far, but it seems to indicate that
> something is possibly amiss on this compiler with the MemSet macros.

That's weird.  Is it too stupid to figure out that the if() inside
MemSet evaluates to constant false in these calls?  It seems hard to
see how it would realize that the loop will write 16 bytes if it doesn't
propagate the constant value forward.

However ... on some other compilers, I've noticed that the compiler seems
more likely to make "obvious" deductions of that sort if the variables in
question are marked const.  Does it help if you do

-		void   *_vstart = (void *) (start); \
-		int		_val = (val); \
-		Size	_len = (len); \
+		void   * const _vstart = (void *) (start); \
+		const int	_val = (val); \
+		const Size	_len = (len); \


I don't think there's any strong reason not to just do s/MemSet/memset/
in these calls and nearby ones, but it would be good to understand just
what's wrong here.  And why it's only showing up in that file; seems
nearly certain that we have similar coding elsewhere.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (18+ messages)  latest in thread

Message-ID: <8649.1505951694@sss.pgh.pa.us>
Permalink:  ../8649.1505951694@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8649.1505951694@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew.dunstan@2ndquadrant.com
  Subject: Re: Windows warnings from VS 2017
  In-Reply-To: <8649.1505951694@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox