[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 10:06:23 PDT 2017
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
More information about the cfe-commits
mailing list