alexfh added a comment.

In https://reviews.llvm.org/D34002#776948, @chh wrote:

> Thanks for providing the ODR reason for Android -fno-exceptions users to 
> change source code or suppress this warning themselves.


I'm not sure I understand your comment. Could you clarify?

Here's an explanation about the possibility of an ODR violation in case the 
compiler would assume `noexcept` for all functions compiled with 
`-fno-exceptions`. Consider the following code:
a.h:

  struct A {
    A(A&&);
    A(const A&);
    ...
  };

b.cc:

  #include "a.h"
  #include <vector>
  ...
    std::vector<A> v1;
  ...

c.cc:

  #include "a.h"
  #include <vector>
  ...
    std::vector<A> v2;
  ...

Now if we compile b.cc with `-fexceptions` and c.cc with `-fno-exceptions`, and 
IF the compiler was changed to treat all functions in c.cc as `noexcept`, then 
the instantiation of some methods of std::vector<A> in b.cc would use the copy 
constructor of A, but the same methods would use the move constructor of A in 
c.cc. When these two were linked together, that would be an ODR violation.


https://reviews.llvm.org/D34002



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

Reply via email to