[cfe-users] ABI change with unused function argument

Gael Guennebaud gael.guennebaud at gmail.com
Mon Feb 24 08:58:37 PST 2014


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

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:


Does clang proposes a cleaner and more general workaround for such an issue?



More information about the cfe-users mailing list