Hello,

I would like to ask what is wrong with the following code:
```

#include <optional>

struct S
{
   S& operator=(S&) { return *this; };
};

void thisWillNotCompileInClang()
{
  std::optional<S> a;
}

```

Compilation command is `g++ or clang++ -std=c++17 -c source.cpp`. It compiles without problems with g++ 9.3.0, but not with clang++ 10.0.0 (both from current stable Ubuntu 20). This code is simplification of code using widely adopted rapidjson library which uses assignment operator with non-const parameter a lot. Earlier versions of clang did not complain (tried with 7.0.1 on currently stable Debian Buster).

Thank you very much for your time and explanation. Kind regards,

Pavel Cernohorsky

_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to