Skip to content

clang will not accept certain std::bind usages when -stdlib=libc++ is specified. #64445

@edfvogel

Description

@edfvogel

The following (very contrived) program shows a program that is accepted when the g++ headers are used, but not when the libc++ headers are used.

Not sure if this is a bug in libc++, but it can pose a porting issue. Any comments are welcome.

Thanks so much,

Ed Vogel

Here is the reproducer from a cygwin session:

$ cat b1.cpp
#include <functional>
#include <stddef.h>
using namespace std;
struct sockaddr {
  int a;
  int b;
};
extern "C" {
  int bind (int, const struct sockaddr *, size_t);
}
void f (void) {
  int sock2;
  sock2 = bind(sock2, (struct sockaddr *)&sock2, sizeof(sock2));
}

VogelEd@XLB3502Q4E ~
$ clang -c b1.cpp

VogelEd@XLB3502Q4E ~
$ clang -c -stdlib=libc++ b1.cpp
b1.cpp:13:11: error: assigning to 'int' from incompatible type '__bind<int &,
      sockaddr *, unsigned long>'
  sock2 = bind(sock2, (struct sockaddr *)&sock2, sizeof(sock2));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Note that if there is no assignment of the return value, the program compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.wontfixIssue is real, but we can't or won't fix it. Not invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions