This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Decorate string_view members with nonnull attribute
- From: Martin Sebor <msebor at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jun 2018 10:46:39 -0600
- Subject: Re: [PATCH] Decorate string_view members with nonnull attribute
- References: <20180613163030.GA23501@redhat.com>
On 06/13/2018 10:30 AM, Jonathan Wakely wrote:
The C++ committee has confirmed that passing a null pointer to the
unary basic_string_view constructor is undefined. This removes the check
from our implementation, and adds the nonnull attribute to warn when the
compiler can detect undefined input.
Any objections to this change?
I have a general question about using the new C++ attributes in
libstdc++ (standard or otherwise): what does C++ have to say about
programs that define macros with the same names? E.g., is this
a valid program?
#define nonnull "..."
...
#include <string_view>
How about:
#define noreturn "..."
...
#include <string_view>
The view in WG14 is that the corresponding C programs (if C2X
were to adopt the proposed C++ attributes) would be valid and
that it's up to implementations to make it work.
Martin