[llvm-bugs] [Bug 47806] New: std::bind presents with #include <string>

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 12 11:52:29 PDT 2020


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

            Bug ID: 47806
           Summary: std::bind presents with #include <string>
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Standards Issues
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yichen.yan at inf.ethz.ch
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 24048
  --> https://bugs.llvm.org/attachment.cgi?id=24048&action=edit
test.cc

for libc++ version >= 7 I got this on Linux:

std::bind will be included if we `#include <string>`

```
root at 6a7daac39000:/# /llvm-install/bin/clang++ --version
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
f2e08c688e6c3223d14c4817c5ce0b55c03a8d1b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /llvm-install/bin
root at 6a7daac39000:/# /llvm-install/bin/clang++ -c -o /dev/null test.cc
test.cc:4:5: warning: expression result unused [-Wunused-value]
    (unsigned int) bind(0, 0, 0);
    ^              ~~~~~~~~~~~~~
test.cc:10:5: warning: expression result unused [-Wunused-value]
    (unsigned int) bind(0, 0, 0);
    ^              ~~~~~~~~~~~~~
2 warnings generated.
root at 6a7daac39000:/# /llvm-install/bin/clang++ -c -o /dev/null -stdlib=libc++
test.cc
test.cc:4:5: warning: expression result unused [-Wunused-value]
    (unsigned int) bind(0, 0, 0);
    ^              ~~~~~~~~~~~~~
test.cc:10:5: error: cannot convert '__bind<int, int, int>' to 'unsigned int'
without a conversion operator
    (unsigned int) bind(0, 0, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.

root at 6a7daac39000:/# cat test.cc
#include <sys/socket.h>
void test1() {
    // posix bind socket
    (unsigned int) bind(0, 0, 0);
}
#include <string>
using namespace std;
void test2() {
    // std::bind
    (unsigned int) bind(0, 0, 0);
}
```

-- 
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/20201012/3cbe938c/attachment.html>


More information about the llvm-bugs mailing list