[llvm-bugs] [Bug 36996] New: libc++ tests compare std::fpos with int

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 3 14:57:50 PDT 2018


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

            Bug ID: 36996
           Summary: libc++ tests compare std::fpos with int
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: billy.oneal at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Libc++ tests, such as
test\std\input.output\file.streams\fstreams\filebuf.virtuals\seekoff.pass.cpp
contain asserts like the following:

typedef std::filebuf::pos_type pos_type;
...
pos_type p = /* ... */
assert(p == 11);

The assert line fails to compile on MSVC because overloads have similar
conversions. Either a user defined conversion can be done from fpos to
streamoff, and then the streamoff compared with int, or the int can be
converted to a streamoff converted into an fpos, and the fpos instances
compared.

.\src\qa\vc\Libs\libcxx\upstream\test\std\input.output\file.streams\fstreams\filebuf.virtuals\seekoff.pass.cpp(35):
error C2666: 'std::fpos<_Mbstatet>::operator ==': 3 overloads have similar
conversions
D:\msvc\binaries\x86ret\inc\iosfwd(101): note: could be 'bool
std::fpos<_Mbstatet>::operator ==(std::streamoff) const'
D:\msvc\binaries\x86ret\inc\iosfwd(96): note: or       'bool
std::fpos<_Mbstatet>::operator ==(const std::fpos<_Mbstatet> &) const'
[ ... ]
.\src\qa\vc\Libs\libcxx\upstream\test\std\input.output\file.streams\fstreams\filebuf.virtuals\seekoff.pass.cpp(35):
note: or       'built-in C++ operator==(std::streamoff, int)'
.\src\qa\vc\Libs\libcxx\upstream\test\std\input.output\file.streams\fstreams\filebuf.virtuals\seekoff.pass.cpp(35):
note: while trying to match the argument list '(pos_type, int)'

[fpos.operations] Table 104 only allows comparison of an fpos with other fpos
instances, not with int. Either the tests should cast the integral value into
an fpos before doing the comparison, or the fpos should be cast to a streamsize
or streamoff.

(Billy is willing to submit a change to resolve this bug but isn't sure which
way you want the cast to go)

-- 
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/20180403/e8a7e83e/attachment.html>


More information about the llvm-bugs mailing list