[cxx-abi-dev] lambda ABI inline function ODR compatibility issue

Lawrence Crowl crowl at googlers.com
Thu Jan 17 21:50:52 UTC 2013


On 1/16/13, Michael Wong <michaelw at ca.ibm.com> wrote:
> Does the C++ Standard committee intend for the ODR to imply that lambdas
> need to have an ABI specified layout in order to deal with inline
> functions.

I believe that we thought it was not an issue.

>
> Consider the following with one object compiled with -DMAIN and another
> without:
> - in one case the layout needs to be compatible between different
> implementations since the static local is shared between translation units
>
> /data/a.o: In function `main':
> a.cpp:(.text+0x18): undefined reference to `bar()'
> collect2: error: ld returned 1 exit status
>
> - in the other case, the layout needs to be compatible between different
> implementations in order to satisfy the ODR requirement that the program
> behave as if there was only one definition of the inline function
>
> extern "C" int printf(const char *, ...);
> extern long gz;
>
> inline void foo() {
>    long x = 0, q = 0, &z = gz;
>    static auto f = [=, &z]() mutable { q += ++x; gz = q + x; };
>
>    long a, b;
>    auto ff = [=]{ sizeof(a /*not an odr-use*/), printf("%u\n", &b < &a); };
>    f();
>    ff();
> }
>
> void bar();
>
> #if ! MAIN
> void bar() { foo(); }
> #else
> long gz;
> int main() {
>    foo();
>    bar();
>    foo();
>    return gz;
> }
> #endif

And this code demonstrates that it is an issue.

Do you have a proposal?

>
> I apologize if this issue has been dealt with.
>
> Regards, Michael
>
> OpenMP CEO:
> http://openmp.org/wp/about-openmp/
> My Blogs:
> http://ibm.co/pCvPHR
> C++11 status:
> http://tinyurl.com/43y8xgf
> Boost test results
> http://www.ibm.com/support/docview.wss?rs=2239&context=SSJT9L&uid=swg27006911
>
> C/C++ Compilers Support/Feature Request Page
> http://www.ibm.com/software/awdtools/ccompilers/support/
> http://www.ibm.com/support/docview.wss?uid=swg27005811
> STM:
> https://sites.google.com/site/tmforcplusplus/
>
> Director & Vice President ISOCPP.org
> Canada and IBM C++Standard HoD
> Chair of WG21 SG5 Transactional Memory
>
> XL C++ Compiler kernel Development
> IBM Canada Ltd., C2/KD2/8200/MKM
> 8200 Warden Avenue
> Markham, Ontario  L6G 1C7
> W:905-413-3283 F:905-413-4839


-- 
Lawrence Crowl


More information about the cxx-abi-dev mailing list