<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jun 17, 2013, at 11:02 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mon, Jun 17, 2013 at 9:21 AM, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Jun 11, 2013, at 6:02 AM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>><br>wrote:<br><br>On 10 June 2013 19:08, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br><br>Richard pointed out on IRC that the patch should look at the<br>redeclaration context to avoid problems with one of the functions<br>being in a extern "C++". Implementing that found some interesting<br>problems. Consider<br><br>extern "C" {<br>static void foo(int x);<br>static void foo() {<br>}<br>void foo(int x) {<br>}<br>}<br><br>This should be valid, since both functions have internal linkage and<br>therefore none of them has C language linkage. Commenting the first<br>declaration makes the code invalid as now the last one is extern C and<br>[dcl.link] p6 kicks in. This means we have to do "normal" overload<br>resolution first to see if the last decl we are looking at has C<br>language linkage or not.<br><br><br>BTW, is this sufficient evidence that we should just give static<br>functions C language linkage? I just checked <a href="http://gcc.godbolt.org/">http://gcc.godbolt.org/</a><br>and gcc 4.8 and icc 13 (which is edg based, no?), reject<br><br>extern "C" {<br>static void foo() {<br>}<br>static void foo(int x) {<br>}<br>}<br><br>We are putting quiet a bit of effort to make sure we accept it and I<br>still can't see the value.<br><br><br>I, too, find this behavior strange. Changing between static and non-static<br>shouldn’t affect whether a function can be overloaded; it’s completely<br>non-intuitive and apparently at odds with existing practice in GCC/EDG.<br></blockquote><br>The latter, at least, is not the case; EDG accepts this code in both<br>its compliant mode and in its g++-compatible mode. I'm surprised that<br>ICC rejects this. </div></blockquote><div dir="auto"><br></div><div dir="auto">Ah, interesting. Might be one of the many compatibility knobs that EDG provides.</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The former makes some degree of sense to me -- a<br>'static' declaration doesn't have external linkage and thus doesn't<br>have C linkage -- although I agree that it's weird.</div></blockquote></div><div><br></div><div>So existing practice is mixed, with a bias toward rejecting the code above (apparently, MSVC also rejects the code in question). The standard is clear that the code is well-formed, but we find that result to be weird. This is starting to feel like a case where we badger the committee into fixing the standard :)</div><br><div><span class="Apple-tab-span" style="white-space:pre"> </span>- Doug</div><div><br></div></body></html>