<div dir="ltr"><div>Thanks for the bug report.</div><div><br></div>This has been fixed in r214699.  In the future, please files bugs here: <a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Aug 2, 2014 at 6:01 AM, Tom Honermann <span dir="ltr"><<a href="mailto:thonermann@coverity.com" target="_blank">thonermann@coverity.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It appears that BlockDecl instances at global scope are not being given unique names for mangling purposes.  The following test aborts when compiled with Clang trunk (r214613)<br>
<br>
$ cat block-mangling.cpp<br>
extern "C" void abort();<br>
#define assert(x) ((x) ? (void)0 : abort())<br>
<br>
template<typename T><br>
int tf() {<br>
    return T::value;<br>
}<br>
<br>
int i1 = ^int {<br>
    struct S { enum { value = 1 };};<br>
    return tf<S>();<br>
}();<br>
int i2 = ^int(int p1) {<br>
    struct S { enum { value = 2 };};<br>
    return tf<S>() + p1;<br>
}(1);<br>
<br>
int main() {<br>
    assert(i1 == 1);<br>
    assert(i2 == 3);<br>
}<br>
<br>
$ clang -fblocks -std=c++11 block-mangling.cpp -o block-mangling -lBlocksRuntime<br>
<br>
$ ./block-mangling<br>
Aborted (core dumped)<br>
<br>
$ nm block-mangling<br>
...<br>
0000000000400590 t _Z2tfIZUb_E1SEiv<br>
...<br>
<br>
Note that only one specialization of template function tf() is present in the executable produced.  There should have been two, one for each block literal in the test program.<br>
<br>
The analogous test using C++11 lambda expressions runs as expected.<br>
<br>
$ cat lambda-mangling.cpp<br>
extern "C" void abort();<br>
#define assert(x) ((x) ? (void)0 : abort())<br>
<br>
template<typename T><br>
int tf() {<br>
    return T::value;<br>
}<br>
<br>
int i1 = [] {<br>
    struct S { enum { value = 1 };};<br>
    return tf<S>();<br>
}();<br>
int i2 = [](int p1) {<br>
    struct S { enum { value = 2 };};<br>
    return tf<S>() + p1;<br>
}(1);<br>
<br>
int main() {<br>
    assert(i1 == 1);<br>
    assert(i2 == 3);<br>
}<br>
<br>
$ clang -std=c++11 lambda-mangling.cpp -o lambda-mangling<br>
<br>
$ ./lambda-mangling<br>
$ echo $?<br>
0<br>
<br>
$ nm lambda-mangling<br>
...<br>
0000000000400600 t _Z2tfIZNK3$_0clEvE1SEiv<br>
00000000004005f0 t _Z2tfIZNK3$_1clEiE1SEiv<br>
...<br>
<br>
Note that two specializations of template function tf() are present in the lambda case.<br>
<br>
Tom.<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>