public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110133] New: System error message should ideally use strerror_r over strerror
@ 2023-06-05 22:35 romain.geissler at amadeus dot com
  2023-06-05 23:21 ` [Bug libstdc++/110133] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: romain.geissler at amadeus dot com @ 2023-06-05 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110133
           Summary: System error message should ideally use strerror_r
                    over strerror
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: romain.geissler at amadeus dot com
  Target Milestone: ---

Hi,

Checking the source code, it seems that the underlying implementation of
generic_category/system_category message() function uses this code:

    return string(strerror(i));

which happens to be thread safe when targetting glibc, but that remains an
implementation details, and not necessarily all libc implement this behavior.
Ideally strerror_r shall be used when available.

Note that unfortunately, glibc has two strerror_r implementations, with a
different return type and thus a different behavior. As an example to cope with
both behavior libc++ choose to use this overloading mechanism:
https://github.com/llvm/llvm-project/blob/2bd82c5462d511f1e58e7d9a4dcd5628cd16a32d/libcxx/src/system_error.cpp#LL114C8-L114C21

In the gcc project, the maintainers of libgfortran have implemented a similar
change this way:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=723553bdc16695ecc686a2ffdff6d15bd600b676;hp=62f9aedcd0a97001f290a1c13fa66efd207a23cc

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

end of thread, other threads:[~2023-12-06 14:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 22:35 [Bug libstdc++/110133] New: System error message should ideally use strerror_r over strerror romain.geissler at amadeus dot com
2023-06-05 23:21 ` [Bug libstdc++/110133] " redi at gcc dot gnu.org
2023-06-05 23:23 ` redi at gcc dot gnu.org
2023-11-04  8:44 ` cvs-commit at gcc dot gnu.org
2023-12-06 14:44 ` cvs-commit at gcc dot gnu.org
2023-12-06 14:45 ` redi 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).