This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/80810] New: char_traits members taking reference arguments instead of values


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

            Bug ID: 80810
           Summary: char_traits members taking reference arguments instead
                    of values
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

As I was browsing libstdc++ code I noticed subtle inconsistencies between the
arguments of some char_traits members and the standard.  For instance:

      static _GLIBCXX_CONSTEXPR bool
      eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
      { return __c1 == __c2; }

takes its arguments by const reference while C++ specifies by-value:

  static constexpr bool eq(char_type c1, char_type c2) noexcept;

The standard itself is inconsistent, specifying some members to take their
arguments by const reference and others by value.  For instance:

  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;

vs

  static char_type* assign(char_type* s, size_t n, char_type a);

(I'm not sure if it has some meaning that the former is noexcept and the latter
isn't.)

I can't imagine that this matters either way, except that the signatures of the
traits members have been changed between 1998 and the current draft, so
presumably there must have been some reason to introduce the inconsistencies,
and libstdc++, while inconsistent, is not inconsistent exactly as prescribed ;)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]