[llvm-bugs] [Bug 52155] New: Calling sync() when rdbuf() is a null pointer should return -1.
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 12 09:04:00 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52155
Bug ID: 52155
Summary: Calling sync() when rdbuf() is a null pointer should
return -1.
Product: libc++
Version: 11.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: edward.vogel at hpe.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
The Standard doc for the sync() function states:
if rdbuf() is a null pointer, returns -1.
It appears libc++ is missing this check.
Here's a cut/paste from a cygwin session:
$ cat t1.cpp
#include <istream>
extern "C" int printf(const char *a,...);
using namespace std;
int main() {
istream x(0);
int s = x.sync();
printf("value is %d\n",s);
}
VogelEd at XLB3502Q4E ~/tests
$ clang++ t1.cpp -o a.out
VogelEd at XLB3502Q4E ~/tests
$ ./a.out
value is -1
VogelEd at XLB3502Q4E ~/tests
$ clang++ -stdlib=libc++ t1.cpp -o a.out
VogelEd at XLB3502Q4E ~/tests
$ ./a.out
value is 0
Note that the g++ library gets this right, but libc++ does not. Visual Studio
2019 also gives the correct answer.
Not a big deal, but I thought I'd post it.
Thanks,
Ed Vogel
--
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/20211012/4803d288/attachment-0001.html>
More information about the llvm-bugs
mailing list