* Strange test in stdalign.m4
@ 2013-03-29 14:57 Eli Zaretskii
2013-03-29 16:53 ` Paul Eggert
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2013-03-29 14:57 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-29 14:57 Strange test in stdalign.m4 Eli Zaretskii
@ 2013-03-29 16:53 ` Paul Eggert
2013-03-29 17:25 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2013-03-29 16:53 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
On 03/29/2013 07:57 AM, Eli Zaretskii wrote:
> I tried this with 2 different versions of GCC on 2 different systems,
> with the same results.
The test works for me, with GCC 4.7.2 and 4.8.0. But you're right, it
does rely on an extension to ISO C11. Which GCC versions
were you using? The test should
be ported to them. Does it fix things for you
if we replace the last four lines of the test with this?
#if (__GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C ||
1300 <= _MSC_VER)
struct alignas_test { char c; int alignas (8) alignas_int; }
alignas_test = { 1, 1 };
char test_alignas[offsetof (struct alignas_test, alignas_int) == 8 ?
1 : -1];
#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-29 16:53 ` Paul Eggert
@ 2013-03-29 17:25 ` Eli Zaretskii
2013-03-30 2:42 ` Paul Eggert
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2013-03-29 17:25 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> Date: Fri, 29 Mar 2013 09:53:38 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
>
> On 03/29/2013 07:57 AM, Eli Zaretskii wrote:
> > I tried this with 2 different versions of GCC on 2 different systems,
> > with the same results.
> The test works for me, with GCC 4.7.2 and 4.8.0. But you're right, it
> does rely on an extension to ISO C11. Which GCC versions
> were you using?
The newest one was 4.4.3 (on fencepost). This is the best I can do
this weekend ;-)
> The test should be ported to them. Does it fix things for you if we
> replace the last four lines of the test with this?
>
> #if (__GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C ||
> 1300 <= _MSC_VER)
> struct alignas_test { char c; int alignas (8) alignas_int; }
> alignas_test = { 1, 1 };
> char test_alignas[offsetof (struct alignas_test, alignas_int) == 8 ?
> 1 : -1];
> #endif
Yes, this works. Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-29 17:25 ` Eli Zaretskii
@ 2013-03-30 2:42 ` Paul Eggert
2013-03-30 5:58 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2013-03-30 2:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
On 03/29/2013 10:25 AM, Eli Zaretskii wrote:
>> The test works for me, with GCC 4.7.2 and 4.8.0. But you're right, it
>> > does rely on an extension to ISO C11. Which GCC versions
>> > were you using?
> The newest one was 4.4.3 (on fencepost).
But fencepost GCC 4.4.3 lacks stdalign.h, which means the test program
that you gave should fail to compile, and the stdalign.h test's failure
to compile under GCC 4.4.3 is a feature not a bug. I.e., although
you've found a portability problem in that test, I don't see how
the problem is relevant to GCC 4.4.3.
You mentioned earlier that you saw 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’
Which compiler version emitted these diagnostics?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-30 2:42 ` Paul Eggert
@ 2013-03-30 5:58 ` Eli Zaretskii
2013-03-30 17:32 ` Paul Eggert
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2013-03-30 5:58 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> Date: Fri, 29 Mar 2013 19:42:13 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
>
> On 03/29/2013 10:25 AM, Eli Zaretskii wrote:
> >> The test works for me, with GCC 4.7.2 and 4.8.0. But you're right, it
> >> > does rely on an extension to ISO C11. Which GCC versions
> >> > were you using?
> > The newest one was 4.4.3 (on fencepost).
>
> But fencepost GCC 4.4.3 lacks stdalign.h, which means the test program
> that you gave should fail to compile, and the stdalign.h test's failure
> to compile under GCC 4.4.3 is a feature not a bug. I.e., although
> you've found a portability problem in that test, I don't see how
> the problem is relevant to GCC 4.4.3.
Yes, I know there's no stdalign.h on fencepost, but I injected the
contents of gnulib's stdalign.h as a preamble to the test program, to
see if it will work.
The goal was to see whether the problem is specific to the (older)
version of GCC I have on the particular Windows box where I first saw
the failure.
> You mentioned earlier that you saw 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’
>
> Which compiler version emitted these diagnostics?
The one on fencepost.
The broader context of this is running the configure script on a
Windows machine, where I arrange for the configure tests to use the
header files in the nt/inc directory in order to pass some of the
tests, which would have failed if only the system headers were used.
In nt/inc, we have stdalign.h that is a copy of lib/stdalign.h, but
the compiler might still be old.
If you'd prefer not to modify the gnulib test (although I don't see
downsides to that), I can force configure to accept nt/inc/stdalign.h
by setting an autoconf variable, although I think fixing the test is
cleaner. I just was stumped by the failure and didn't understand what
was going on.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-30 5:58 ` Eli Zaretskii
@ 2013-03-30 17:32 ` Paul Eggert
2013-03-30 17:40 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2013-03-30 17:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
On 03/29/13 22:58, Eli Zaretskii wrote:
> The broader context of this is running the configure script on a
> Windows machine, where I arrange for the configure tests to use the
> header files in the nt/inc directory
Ah, thanks, I see now. I had already installed a change into gnulib,
and propagated that change into the Emacs trunk just now (bzr 112196);
please give it a try. The change isn't exactly what I sent you earlier
but I think it will work for you and it should be a bit more portable.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange test in stdalign.m4
2013-03-30 17:32 ` Paul Eggert
@ 2013-03-30 17:40 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2013-03-30 17:40 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> Date: Sat, 30 Mar 2013 10:32:01 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
>
> On 03/29/13 22:58, Eli Zaretskii wrote:
> > The broader context of this is running the configure script on a
> > Windows machine, where I arrange for the configure tests to use the
> > header files in the nt/inc directory
>
> Ah, thanks, I see now. I had already installed a change into gnulib,
> and propagated that change into the Emacs trunk just now (bzr 112196);
> please give it a try. The change isn't exactly what I sent you earlier
> but I think it will work for you and it should be a bit more portable.
It does work, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-30 17:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29 14:57 Strange test in stdalign.m4 Eli Zaretskii
2013-03-29 16:53 ` 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
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.