This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Inconsistency with coreutils: _Static_assert()


On 2013-05-21 18:08, Corinna Vinschen wrote:
> On May 21 17:59, Denis Excoffier wrote:
>> Hello,
>> 
>> I compile coreutils-8.21 under Cygwin (Windows XP). I'm using
>> gcc-4.8.0 with no problem, except that under _any_ snapshot
>> posterior to
>> plain 1.7.18, i obtain the following (with plain 1.7.18, or under
>> gcc-4.5.3 it works perfectly):
>> 
>> ---------------
>> ...
>> depbase=`echo src/chroot.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
>> gcc -std=gnu99  -I. -I./lib  -Ilib -I./lib -Isrc -I./src    -g -O2
>> -MT src/chroot.o -MD -MP -MF $depbase.Tpo -c -o src/chroot.o
>> src/chroot.c &&\
>> mv -f $depbase.Tpo $depbase.Po
>> In file included from /usr/include/sys/stdio.h:14:0,
>>                 from /usr/include/stdio.h:62,
>>                 from ./lib/stdio.h:43,
>>                 from src/chroot.c:21:
>> src/chroot.c: In function 'set_additional_groups':
>> ./lib/verify.h:181:8: error: expected specifier-qualifier-list
>> before 'typedef'
>>        _Static_assert (R, DIAGNOSTIC);          \
>>        ^
>> ./lib/verify.h:166:16: note: in expansion of macro '_GL_VERIFY_TYPE'
>>     (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
>>                ^
>> ./lib/verify.h:230:25: note: in expansion of macro '_GL_VERIFY_TRUE'
>> # define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
>>                         ^
>> src/system.h:247:35: note: in expansion of macro 'verify_true'
>> #define X2NREALLOC(P, PN) ((void) verify_true (sizeof *(P) != 1), \
>>                                   ^
>> src/chroot.c:103:16: note: in expansion of macro 'X2NREALLOC'
>>         gids = X2NREALLOC (gids, &n_gids_allocated);
>>                ^
>> Makefile:6662: recipe for target 'src/chroot.o' failed
>> make: *** [src/chroot.o] Error 1
>> ---------------
>> 
>> I have narrowed the problem down to /usr/include/sys/cdefs.h, where
>> (line 271) you have _Static_assert defined:
>> #define _Static_assert(x, y)  __Static_assert(x, __COUNTER__)
>> 
>> This definition occurs even under GCC 4.6.0 (and later) where
>> _Static_assert() indeed works. As a consequence, it no longer works as
>> expected in coreutils-8.21/lib/verify.h (lines 24 and 181).
> 
> Sorry, but I don't grok this sentence.  Since the cdefs.h version
> works as expected, it does not work in coreutils' verify.h?  Who
> exactly is wrong, cdefs.h or verify.h?  And *what* exactly is wrong
> with the definition?
As soon as you are under GCC >= 4.6, _Static_assert() works directly,
hence line 271 of cdefs.h is not needed. More than that, when you
(re)define it to something else, the original behavior is no longer
available, and e.g. coreutils (that is "verify.h") fails to compile.

You should (IMHO) change cdefs.h in order to read (as far as only
_Static_assert is concerned):

#if defined(__cplusplus) && __cplusplus >= 201103L
. . . (same) . . .
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
. . . (same) . . .
#elif (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
/* Do nothing: _Static_assert() works as per C11 */
#else
/* Not supported.  Implement them using our versions. */
. . . (same) . . .
#endif

I don't really know if the lines above correctly take care of
__STRICT_ANSI__ but you get the idea.

Regards,

Denis Excoffier.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]