public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union)
@ 2017-02-22 17:32 Joakim Nohlgård
  2017-02-23  7:13 ` Sebastian Huber
  0 siblings, 1 reply; 4+ messages in thread
From: Joakim Nohlgård @ 2017-02-22 17:32 UTC (permalink / raw)
  To: newlib

Dear developers,
The stdatomic.h header included with newlib gives compilation errors
with recent GCC versions.

GCC includes its own stdatomic.h, which works fine, but given that
there are preprocessor conditionals in newlib's stdatomic.h for GCC
makes me believe it has compiled OK at some point.

% printf '%s\n%s' '#include <stdint.h>' '#include <stdatomic.h>' | \
arm-none-eabi-gcc -nostdinc \
-isystem /usr/arm-none-eabi/include \
-isystem /usr/lib/gcc/arm-none-eabi/5.4.0/include \
-x c -o /dev/null -c -

In file included from <stdin>:2:0:
/usr/arm-none-eabi/include/stdatomic.h: In function
‘atomic_flag_test_and_set_explicit’:
/usr/arm-none-eabi/include/stdatomic.h:386:10: error: request for
member ‘__val’ in something not a structure or union
  return (atomic_exchange_explicit(&__object->__flag, 1, __order));
          ^
/usr/arm-none-eabi/include/stdatomic.h: In function
‘atomic_flag_clear_explicit’:
/usr/arm-none-eabi/include/stdatomic.h:393:2: error: request for
member ‘__val’ in something not a structure or union
  atomic_store_explicit(&__object->__flag, 0, __order);
  ^

Building for i686-elf additionally gives errors about argument types:
% printf '%s\n%s' '#include <stdint.h>' '#include <stdatomic.h>' | \
i686-elf-gcc -nostdinc \
-isystem /usr/i686-elf/include \
-isystem /usr/lib/gcc/i686-elf/5.4.0/include \
-x c -o /dev/null -c -

/usr/i686-elf/include/stdatomic.h: In function
‘atomic_flag_test_and_set_explicit’:
/usr/i686-elf/include/stdatomic.h:386:10: error: request for member
‘__val’ in something not a structure or union
  return (atomic_exchange_explicit(&__object->__flag, 1, __order));
          ^
/usr/i686-elf/include/stdatomic.h:386:2: error: incompatible type for
argument 1 of ‘__atomic_exchange_n’
  return (atomic_exchange_explicit(&__object->__flag, 1, __order));
  ^
/usr/i686-elf/include/stdatomic.h: In function ‘atomic_flag_clear_explicit’:
/usr/i686-elf/include/stdatomic.h:393:2: error: request for member
‘__val’ in something not a structure or union
  atomic_store_explicit(&__object->__flag, 0, __order);
  ^
/usr/i686-elf/include/stdatomic.h:393:2: error: incompatible type for
argument 1 of ‘__atomic_store_n’
  atomic_store_explicit(&__object->__flag, 0, __order);
  ^

I have no idea on what would be a proper fix though.

Best regards,
Joakim Nohlgård

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union)
  2017-02-22 17:32 stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union) Joakim Nohlgård
@ 2017-02-23  7:13 ` Sebastian Huber
  2017-02-23 10:17   ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Huber @ 2017-02-23  7:13 UTC (permalink / raw)
  To: Joakim Nohlgård, newlib

This file worked before GCC shipped its own stdatomic.h. You should use 
the GCC provided stdatomic.h. Maybe we should remove the stdatomic.h 
from Newlib.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union)
  2017-02-23  7:13 ` Sebastian Huber
@ 2017-02-23 10:17   ` Corinna Vinschen
  2017-02-23 10:19     ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2017-02-23 10:17 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]

On Feb 23 08:13, Sebastian Huber wrote:
> This file worked before GCC shipped its own stdatomic.h. You should use the
> GCC provided stdatomic.h. Maybe we should remove the stdatomic.h from
> Newlib.

We should continue to provide it for older GCC versions.  We could
do something like

  #if __GNUC_PREREQ__(X,Y)
  #undef _STDATOMIC_H_
  #include_next <stdatomic.h>
  #else
  [rest of our own stdatomic.h]
  #endif

X.Y would be the 1st gcc version providing its own stdatomic.h


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union)
  2017-02-23 10:17   ` Corinna Vinschen
@ 2017-02-23 10:19     ` Corinna Vinschen
  0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2017-02-23 10:19 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

On Feb 23 11:17, Corinna Vinschen wrote:
> On Feb 23 08:13, Sebastian Huber wrote:
> > This file worked before GCC shipped its own stdatomic.h. You should use the
> > GCC provided stdatomic.h. Maybe we should remove the stdatomic.h from
> > Newlib.
> 
> We should continue to provide it for older GCC versions.  We could
> do something like
> 
>   #if __GNUC_PREREQ__(X,Y)
>   #undef _STDATOMIC_H_

The undef is apparently not even required.  GCC uses _STDATOMIC_H without
trailing underscore.

>   #include_next <stdatomic.h>
>   #else
>   [rest of our own stdatomic.h]
>   #endif
> 
> X.Y would be the 1st gcc version providing its own stdatomic.h


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-23 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 17:32 stdatomic.h broken on GCC-5.4.0 (error: request for member ‘__val’ in something not a structure or union) Joakim Nohlgård
2017-02-23  7:13 ` Sebastian Huber
2017-02-23 10:17   ` Corinna Vinschen
2017-02-23 10:19     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).