[cfe-users] ABI change with unused function argument
David Blaikie
dblaikie at gmail.com
Mon Feb 24 09:18:05 PST 2014
Clang should only be doing this to internal symbols (or it should be making
the symbol internal so it can perform such an optimization). Do you have a
standalone (at least complete, ideally minimal) example of this issue?
On Mon, Feb 24, 2014 at 8:58 AM, Gael Guennebaud
<gael.guennebaud at gmail.com>wrote:
> 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
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140224/3f0ff50c/attachment.html>
More information about the cfe-users
mailing list