Linux Manual Pages development
 help / color / mirror / Atom feed
* [Bug 221533] New: strstr/c23/constness
@ 2026-05-16 16:47 bugzilla-daemon
  2026-05-16 16:57 ` [Bug 221533] strstr/c23/constness bugzilla-daemon
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bugzilla-daemon @ 2026-05-16 16:47 UTC (permalink / raw)
  To: linux-man

https://bugzilla.kernel.org/show_bug.cgi?id=221533

            Bug ID: 221533
           Summary: strstr/c23/constness
           Product: Documentation
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: man-pages
          Assignee: documentation_man-pages@kernel-bugs.osdl.org
          Reporter: linux@treblig.org
        Regression: No

Hi,
  In C23 strstr can return a const char* if the first parameter is a const
char*;  this is also true of a bunch of the other routines.

  I'm not really sure how this should be documented, I guess two entries for
each function with some note saying it's only C23 and later?

See:
https://sourceware.org/cgit/glibc/commit/string/string.h?id=cd748a63ab1a7ae846175c532a3daab341c62690

for the glibc change that implemented it.

It can break some existing code, e.g. something like:


int foo(const char *a)
{
   char *bar = strstr(a, "frog");
}

gives:
t.c:9:16: warning: initialization discards ‘const’ qualifier from pointer
target type [-Wdiscarded-qualifiers]
    9 |    char *bar = strstr(a, "frog");
      |                ^~~~~~

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

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

end of thread, other threads:[~2026-05-17  7:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-16 16:47 [Bug 221533] New: strstr/c23/constness bugzilla-daemon
2026-05-16 16:57 ` [Bug 221533] strstr/c23/constness bugzilla-daemon
2026-05-16 17:18 ` bugzilla-daemon
2026-05-17  7:36 ` bugzilla-daemon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox