NetBSD Problem Report #52571
From www@NetBSD.org Mon Sep 25 16:54:16 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1A4957A212
for <gnats-bugs@gnats.NetBSD.org>; Mon, 25 Sep 2017 16:54:16 +0000 (UTC)
Message-Id: <20170925165415.4DB217A297@mollari.NetBSD.org>
Date: Mon, 25 Sep 2017 16:54:15 +0000 (UTC)
From: bruno@clisp.org
Reply-To: bruno@clisp.org
To: gnats-bugs@NetBSD.org
Subject: max_align_t has smaller alignment than double
X-Send-Pr-Version: www-1.0
>Number: 52571
>Category: standards
>Synopsis: max_align_t has smaller alignment than double
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 25 16:55:00 +0000 2017
>Last-Modified: Tue Sep 26 09:00:01 +0000 2017
>Originator: Bruno Haible
>Release: netbsd-8 201709170600Z
>Organization:
GNU
>Environment:
NetBSD netbsd8 8.0_BETA NetBSD 8.0_BETA (GENERIC.201709170600Z) i386
>Description:
max_align_t is supposed to have the largest alignment among the standard C types. But here, __alignof__(max_align_t) < __alignof__(double).
This breaks compilation of some GNU packages, because gnulib has a compile-time assertion:
verify(__alignof__ (double) <= __alignof__ (max_align_t));
>How-To-Repeat:
Compile this file:
=============================
#include <stddef.h>
int aaa = __alignof__(double);
int aab = __alignof__(max_align_t);
=============================
gcc -S x.c
You can see that aaa has the value 8, whereas aab has the value 4.
>Fix:
>Audit-Trail:
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: standards-manager@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: standards/52571: max_align_t has smaller alignment than double
Date: Tue, 26 Sep 2017 10:57:18 +0200
On Mon, Sep 25, 2017 at 04:55:00PM +0000, bruno@clisp.org wrote:
> max_align_t is supposed to have the largest alignment among the
> standard C types. But here, __alignof__(max_align_t) < __alignof__(double).
So this one is a nice excercise in GCC extensions and why they sometimes
don't give you what you think they do. Compare the following test case
on i386 with and without USE_ALIGNOF:
#include <stddef.h>
struct foo {
double x;
char t;
};
int main() {
#ifdef USE_ALIGNOF
return __alignof__(double);
#else
return sizeof(struct foo) - offsetof(struct foo, t);
#endif
}
---
For the SYSV ABI (not the bastardized version Linux is nowadays using),
the ABI alignment of double is 32bit, but most compiler use a prefered
alignment of 64bit. Similar for long double.
Joerg
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.