[llvm-bugs] [Bug 48814] New: Error in num_get::do_get for custom character type

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 20 04:12:17 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48814

            Bug ID: 48814
           Summary: Error in num_get::do_get for custom character type
           Product: libc++
           Version: 11.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

template <class _CharT, class _InputIterator>
_InputIterator
num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
                                        ios_base& __iob,
                                        ios_base::iostate& __err,
                                        void*& __v) const
{
    // Stage 1
    int __base = 16;
    // Stage 2
    char_type __atoms[26];
    char_type __thousands_sep = 0;

This assumes that char_type can be unambiguously constructed from an int, but
that isn't necessarily true. Consider a character-like class type (with
appropriate specialization of char_traits):

struct charlike
{
  charlike() = default;
  charlike(char);
  charlike(wchar_t);
  // ...
};

This will give an error in num_get, as seen at:
https://github.com/maekitalo/cxxtools/issues/27

Using "char_type __thousands_sep = char_type();" should work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210120/9e85cd98/attachment.html>


More information about the llvm-bugs mailing list