public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc: Bruno De Fraine <Bruno.DeFraine@synopsys.com>,
	"newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: newlib header breaks restricted pointers in C++
Date: Tue, 25 Jul 2023 20:48:35 +0200	[thread overview]
Message-ID: <ZMAZA1r+fNty6/BK@calimero.vinschen.de> (raw)
In-Reply-To: <3126b987-ca19-97f6-9c7a-06243add9354@embedded-brains.de>

On Jul 25 19:46, Sebastian Huber wrote:
> On 25.07.23 19:35, Corinna Vinschen wrote:
> > Hi Bruno,
> > 
> > On Jul 24 22:23, Bruno De Fraine wrote:
> > > Hello,
> > > 
> > > As an extension, GCC and clang offer C99-style restricted pointers in C++ mode:
> > > https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html
> > > 
> > > We notice that this extension is broken when including newlib headers: restricted pointers are treated as ordinary pointers.
> > > 
> > > We traced this to the following section of newlib/libc/include/sys/cdefs.h:
> > > 
> > >    /*
> > >     * GCC 2.95 provides `__restrict' as an extension to C90 to support the
> > >     * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
> > >     * a way to define the `restrict' type qualifier without disturbing older
> > >     * software that is unaware of C99 keywords.
> > >     */
> > >    #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
> > >    #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
> > >    #define	__restrict
> > >    #else
> > >    #define	__restrict	restrict
> > >    #endif
> > >    #endif
> > > 
> > > While the GCC __restrict extension was indeed introduced in GCC 2.95, it is not limited to this version; the extension is also not limited to C90:
> > > https://gcc.gnu.org/gcc-2.95/c++features.html
> > Either way, the above has been taken from FreeBSD, and it is still,
> > as of today, the same expression as used in FreeBSDs sys/cdefs.h
> > file.
> > 
> > Seb, any input on this?
> 
> I added a FreeBSD bug report:
> 
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272723

Great, thanks!  Do we want to wait for a FreeBSD solution, or do
we want to change it now and, maybe, take the FreeBSD version later?

Does anybody want to provide a git compatible patch?


Thanks,
Corinna


  reply	other threads:[~2023-07-25 18:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 22:23 Bruno De Fraine
2023-07-25 17:35 ` Corinna Vinschen
2023-07-25 17:46   ` Sebastian Huber
2023-07-25 18:48     ` Corinna Vinschen [this message]
2023-07-25 23:48       ` Steven J Abner
2023-07-27  9:00         ` Corinna Vinschen
2023-07-28 14:15           ` Sebastian Huber
2023-07-28 14:42             ` Joel Sherrill
2023-07-31 11:04       ` Bruno De Fraine

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=ZMAZA1r+fNty6/BK@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=Bruno.DeFraine@synopsys.com \
    --cc=newlib@sourceware.org \
    --cc=sebastian.huber@embedded-brains.de \
    /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.
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).