Hi,
I've observed that clang changes the ABI when a function argument is not used.
This is a nice optimization, but the downside is that this introduces
segfaults when an argument is conditionally used with respect to
compilation options (e.g., -DNDEBUG) and that both the application and
a library instantiate this function, but only one is compiled with
-DNDEBUG.
Here is an example of how could look like such a function:
template<int A, typename T>
void foo(int a, T &t) {
assert(A!=0 || a==0);
if(A==0) { /* code making use of both a and t */ }
else { /* code making use of t and A only */ }
}
and you can see a real-world example with a very ugly workaround there:
https://bitbucket.org/eigen/eigen/commits/1e19a9cb83f0/
Does clang proposes a cleaner and more general workaround for such an issue?
Thanks,
Gael
_______________________________________________
cfe-users mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users