Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwtdM-0006N7-4s for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Oct 2016 16:22:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bwtdL-0008Sy-4H for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Oct 2016 16:22:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwtbx-0006x7-Oe for pgsql-hackers@postgreSQL.org; Wed, 19 Oct 2016 16:21:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwtbv-0006X0-08 for pgsql-hackers@postgreSQL.org; Wed, 19 Oct 2016 16:21:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u9JGKs7N012449; Wed, 19 Oct 2016 12:20:55 -0400 From: Tom Lane To: Greg Stark cc: pgsql-hackers@postgreSQL.org Subject: Re: [COMMITTERS] packing/alignment annotation for ItemPointerData redux In-reply-to: References: Comments: In-reply-to Greg Stark message dated "Wed, 19 Oct 2016 16:50:17 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12447.1476894054.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 19 Oct 2016 12:20:54 -0400 Message-ID: <12448.1476894054@sss.pgh.pa.us> X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org [ moved to -hackers ] Greg Stark writes: > Back in 2001 a hack to add __attribute__((packed)) to ItemPtr was > added with a comment "Appropriate whack upside the head for ARM" > (dcbbdb1b3ee). I don't know if this is still a factor in 2016 or not > but it has already resulted in some collateral damage in 2015 when > some compiler took that as license to align the whole struct on single > byte alignment when it was buried inside another struct > (d4b538ea367de). > I just tried compiling with Clang 3.8.0 and got tons of warnings about > this because: > 'ItemPointerData' may result in an unaligned pointer value > [-Waddress-of-packed-member] > ...ItemPointerGetBlockNumber(&(xlrec->target_tid)), > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../../src/include/storage/itemptr.h:69:25: note: expanded from macro > 'ItemPointerGetBlockNumber' > BlockIdGetBlockNumber(&(pointer)->ip_blkid) \ > ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ > ../../../src/include/storage/block.h:118:19: note: expanded from macro > 'BlockIdGetBlockNumber' > (BlockNumber) (((blockId)->bi_hi << 16) | ((uint16) (blockId)->bi= _lo)) \ > ^~~~~~~ > Which seems to indicate that clang may not understand the > "pg_attribute_aligned(2)" or perhaps it does and just doesn't take it > into account when generating these warnings. Ick. Can you look to see how those macros are expanding on your clang? > I'm sure there are other people testing clang -- isn't it the default > on MacOS? Do they not see these warnings? I've never seen this on MacOS. The current compiler version (on Sierra) is $ gcc -v Configured with: --prefix=3D/Applications/Xcode.app/Contents/Developer/usr = --with-gxx-include-dir=3D/Applications/Xcode.app/Contents/Developer/Platfor= ms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1 Apple LLVM version 8.0.0 (clang-800.0.38) Target: x86_64-apple-darwin16.0.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDe= fault.xctoolchain/usr/bin Don't know how that version number compares to "3.8.0". regards, tom lane --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers