public inbox for
 help / color / mirror / Atom feed
From: Corinna Vinschen <>
Subject: Re: newlib header breaks restricted pointers in C++
Date: Thu, 27 Jul 2023 11:00:08 +0200	[thread overview]
Message-ID: <ZMIyGF/> (raw)
In-Reply-To: <>

On Jul 25 19:48, Steven J Abner wrote:
> Curiosity killed the cat,
> I might not understand, could you clarify. It mentions 'restrict is not a
> keyword in C++'.
> So doesn't #if __cpplusplus need to define 'restrict'. Additionally,
> shouldn't the below mentioned
> '#define'(s) include '__restrict__ ?

I don't think the header should really define "restrict" for C++,
it would clobber the namespace.

We have the following scenario:

- GCC defines __restrict (and __restrict__) for C and C++.

- Newlib overloads __restrict for all GCC versions != 2.95.

  - Either to nothing, if the app standard is < C99, or
  - to "restrict" if the app standard is >= C99.

The negated release check for version 2.95 exactly is certainly fishy.

Let's compare with the GLibc version:

  /* __restrict is known in EGCS 1.2 and above, and in clang.
     It works also in C++ mode (outside of arrays), but only when spelled
     as '__restrict', not 'restrict'.  */
  #if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
  # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  #  define __restrict    restrict
  # else
  #  define __restrict    /* Ignore */
  # endif

So the expression is the same, just the version check makes more sense.

Shall we match our version expression to the GLibc expression?


  reply	other threads:[~2023-07-27  9:00 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
2023-07-25 23:48       ` Steven J Abner
2023-07-27  9:00         ` Corinna Vinschen [this message]
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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZMIyGF/ \ \ \

* 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).