From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: Strange test in stdalign.m4
Date: Fri, 29 Mar 2013 17:57:21 +0300 [thread overview]
Message-ID: <8338ve5k4u.fsf@gnu.org> (raw)
The test program from m4/stdalign.m4, viz.:
#include <stdalign.h>
#include <stddef.h>
/* Test that alignof yields a result consistent with offsetof.
This catches GCC bug 52023
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
#ifdef __cplusplus
template <class t> struct alignof_helper { char a; t b; };
# define ao(type) offsetof (alignof_helper<type>, b)
#else
# define ao(type) offsetof (struct { char a; type b; }, b)
#endif
char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
/* Test _Alignas only on platforms where gnulib can help. */
#if (__GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
int alignas (8) alignas_int = 1;
char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1];
#endif
int
main ()
{
return 0;
}
seems to always fail. This line:
char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1];
emits the following diagnostics:
ta.c:36: error: expected specifier-qualifier-list before ‘alignas_int’
ta.c:36: error: ‘struct <anonymous>’ has no member named ‘__b’
My understanding is that _Alignof accepts a data type as its argument,
whereas alignas_int is not a data type. If I use typeof, like this:
char test_alignas[_Alignof (typeof(alignas_int)) == 8 ? 1 : -1];
then the error is
ta.c:36: error: size of array ‘test_alignas’ is negative
which means alignas didn't really work, right?
This fails the configure test of stdalign.h, even if I replace
stdalign.h with lib/stdalign.in.h, a gnulib replacement, which is
supposed to be correct.
I tried this with 2 different versions of GCC on 2 different systems,
with the same results.
What am I missing here? Why does the test fail?
TIA
next reply other threads:[~2013-03-29 14:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 14:57 Eli Zaretskii [this message]
2013-03-29 16:53 ` Strange test in stdalign.m4 Paul Eggert
2013-03-29 17:25 ` Eli Zaretskii
2013-03-30 2:42 ` Paul Eggert
2013-03-30 5:58 ` Eli Zaretskii
2013-03-30 17:32 ` Paul Eggert
2013-03-30 17:40 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8338ve5k4u.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.