public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
@ 2022-11-21  7:25 unlvsur at live dot com
  2022-11-21  9:13 ` [Bug c++/107781] " schwab@linux-m68k.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-11-21  7:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

            Bug ID: 107781
           Summary: strchrnul' was not declared in this scope; did you
                    mean 'strchr'? For contracts for canadian compilation
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

I do canadian compilation and it fails due to contracts.cc

../../../../../gcc/gcc/cp/contracts.cc: In function 'bool role_name_equal(const
char*, const char*)':
../../../../../gcc/gcc/cp/contracts.cc:213:21: error: 'strchrnul' was not
declared in this scope; did you mean 'strchr'?
  213 |   size_t role_len = strchrnul (role, ':') - role;
      |                     ^~~~~~~~~
      |                     strchr

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
@ 2022-11-21  9:13 ` schwab@linux-m68k.org
  2022-11-21 10:35 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab@linux-m68k.org @ 2022-11-21  9:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 107780 has been marked as a duplicate of this bug. ***

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
  2022-11-21  9:13 ` [Bug c++/107781] " schwab@linux-m68k.org
@ 2022-11-21 10:35 ` redi at gcc dot gnu.org
  2022-11-21 14:01 ` dje at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-21 10:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-21
     Ever confirmed|0                           |1
           Keywords|                            |build
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc/2022-November/240070.html

Fails for macOS too. Probably others, as strchrnul is glibc-specific.

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
  2022-11-21  9:13 ` [Bug c++/107781] " schwab@linux-m68k.org
  2022-11-21 10:35 ` redi at gcc dot gnu.org
@ 2022-11-21 14:01 ` dje at gcc dot gnu.org
  2022-11-21 22:44 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dje at gcc dot gnu.org @ 2022-11-21 14:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at gcc dot gnu.org

--- Comment #3 from David Edelsohn <dje at gcc dot gnu.org> ---
AIX as well.

Although, apparently strchrnul() is provided a z/OS extension, so, hey, you can
build it there too! :-P.

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (2 preceding siblings ...)
  2022-11-21 14:01 ` dje at gcc dot gnu.org
@ 2022-11-21 22:44 ` jason at gcc dot gnu.org
  2022-11-22 10:58 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2022-11-21 22:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (3 preceding siblings ...)
  2022-11-21 22:44 ` jason at gcc dot gnu.org
@ 2022-11-22 10:58 ` redi at gcc dot gnu.org
  2022-11-22 11:01 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-22 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If we don't want to introduce a configure check for strchrnul then this would
work:

--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -210,8 +210,8 @@ lookup_concrete_semantic (const char *name)
 static bool
 role_name_equal (const char *role, const char *name)
 {
-  size_t role_len = strchrnul (role, ':') - role;
-  size_t name_len = strchrnul (name, ':') - name;
+  size_t role_len = strcspn (role, ":");
+  size_t name_len = strcspn (name, ":");
   if (role_len != name_len)
     return false;
   return strncmp (role, name, role_len) == 0;

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (4 preceding siblings ...)
  2022-11-22 10:58 ` redi at gcc dot gnu.org
@ 2022-11-22 11:01 ` jakub at gcc dot gnu.org
  2022-11-22 11:04 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-11-22 11:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606940.html

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (5 preceding siblings ...)
  2022-11-22 11:01 ` jakub at gcc dot gnu.org
@ 2022-11-22 11:04 ` jakub at gcc dot gnu.org
  2022-11-22 14:30 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-11-22 11:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> If we don't want to introduce a configure check for strchrnul then this
> would work:
> 
> --- a/gcc/cp/contracts.cc
> +++ b/gcc/cp/contracts.cc
> @@ -210,8 +210,8 @@ lookup_concrete_semantic (const char *name)
>  static bool
>  role_name_equal (const char *role, const char *name)
>  {
> -  size_t role_len = strchrnul (role, ':') - role;
> -  size_t name_len = strchrnul (name, ':') - name;
> +  size_t role_len = strcspn (role, ":");
> +  size_t name_len = strcspn (name, ":");
>    if (role_len != name_len)
>      return false;
>    return strncmp (role, name, role_len) == 0;

Yes, though I bet strcspn is often slower, because it has to support many
reject characters, not just 2 (the one specified plus '\0').
Though, on glibc it won't be much slower, due to:
  if (__glibc_unlikely (reject[0] == '\0')
      || __glibc_unlikely (reject[1] == '\0'))
    return __strchrnul (str, reject [0]) - str;
done at the start of strcspn.

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (6 preceding siblings ...)
  2022-11-22 11:04 ` jakub at gcc dot gnu.org
@ 2022-11-22 14:30 ` cvs-commit at gcc dot gnu.org
  2022-11-22 14:47 ` jason at gcc dot gnu.org
  2022-11-28 22:38 ` [Bug c++/107781] [13 Regression] " pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-22 14:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:ac5054144bd2248e948842937448eb5f4ce36bfd

commit r13-4236-gac5054144bd2248e948842937448eb5f4ce36bfd
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Nov 21 17:42:14 2022 -0500

    c++: don't use strchrnul [PR107781]

    The contracts implementation was using strchrnul, which is a glibc
    extension, so bootstrap broke on non-glibc targets.  Use C89 strcspn
    instead.

            PR c++/107781

    gcc/cp/ChangeLog:

            * contracts.cc (role_name_equal): Use strcspn instead
            of strchrnul.

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

* [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (7 preceding siblings ...)
  2022-11-22 14:30 ` cvs-commit at gcc dot gnu.org
@ 2022-11-22 14:47 ` jason at gcc dot gnu.org
  2022-11-28 22:38 ` [Bug c++/107781] [13 Regression] " pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2022-11-22 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

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

* [Bug c++/107781] [13 Regression] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
  2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
                   ` (8 preceding siblings ...)
  2022-11-22 14:47 ` jason at gcc dot gnu.org
@ 2022-11-28 22:38 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
            Summary|strchrnul' was not declared |[13 Regression] strchrnul'
                   |in this scope; did you mean |was not declared in this
                   |'strchr'? For contracts for |scope; did you mean
                   |canadian compilation        |'strchr'? For contracts for
                   |                            |canadian compilation

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

end of thread, other threads:[~2022-11-28 22:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21  7:25 [Bug c++/107781] New: strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation unlvsur at live dot com
2022-11-21  9:13 ` [Bug c++/107781] " schwab@linux-m68k.org
2022-11-21 10:35 ` redi at gcc dot gnu.org
2022-11-21 14:01 ` dje at gcc dot gnu.org
2022-11-21 22:44 ` jason at gcc dot gnu.org
2022-11-22 10:58 ` redi at gcc dot gnu.org
2022-11-22 11:01 ` jakub at gcc dot gnu.org
2022-11-22 11:04 ` jakub at gcc dot gnu.org
2022-11-22 14:30 ` cvs-commit at gcc dot gnu.org
2022-11-22 14:47 ` jason at gcc dot gnu.org
2022-11-28 22:38 ` [Bug c++/107781] [13 Regression] " pinskia at gcc dot gnu.org

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