Calling sync() when rdbuf() is a null pointer should return -1.
| Bugzilla Link | 52155 |
| Version | 11.0 |
| OS | All |
| CC | @mclow |
Extended Description
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
VogelEd@XLB3502Q4E ~/tests $ clang++ t1.cpp -o a.out
VogelEd@XLB3502Q4E ~/tests $ ./a.out value is -1
VogelEd@XLB3502Q4E ~/tests
$ clang++ -stdlib=libc++ t1.cpp -o a.out
VogelEd@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