<div dir="ltr">I would guess it's the pointer to member, not the static_assert. MSVC has significant problems with casts from the address of a member function to a pointer-to-member type (either a type mismatch due to a calling convention attribute or a failure to resolve overloaded functions properly, I don't remember). We do something similar to this in Clang's RecursiveASTVisitor, and it took a number of iterations to find a form that all of our buildbots were happy with.<div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 3, 2016 at 10:42 AM, David Blaikie via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">possible that static_assert isn't supported on some of the compilers we support, or didn't at some point. I'd check the commit history and if the reason cited (if there is one) doesn't apply anymore, just remove it.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Feb 3, 2016 at 10:16 AM, <Alexander G. Riccio> via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">In <font face="monospace, monospace">Allocator.h</font>, there are two <font face="monospace, monospace">static_assert</font>s that are guarded by an <font face="monospace, monospace">#ifdef __clang__</font>. What's up with that? Shouldn't non <font face="monospace, monospace">__clang__</font> environments be able to do this? Surely there's a better way to check for overloads?<div><div><br></div><div>The two <font face="monospace, monospace">static_assert</font>s in question:<br><br></div><div><pre style="color:gainsboro;background:rgb(30,30,30)"><font face="monospace, monospace">  <span style="color:darkgreen">/// \brief Allocate \a Size bytes of \a Alignment aligned memory. This method</span>
  <span style="color:darkgreen">/// must be implemented by \c DerivedT.</span>
  <span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*</span><span style="color:rgb(200,200,200)">Allocate</span><span style="color:rgb(180,180,180)">(</span><span style="color:rgb(78,201,176)">size_t</span> <span style="color:rgb(127,127,127)">Size</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(78,201,176)">size_t</span> <span style="color:rgb(127,127,127)">Alignment</span><span style="color:rgb(180,180,180)">)</span> <span style="color:rgb(180,180,180)">{</span>
<span style="color:rgb(155,155,155)">#ifdef</span> __clang__
    <span style="color:rgb(86,156,214)">static_assert</span><span style="color:rgb(180,180,180)">(</span><span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*(</span>AllocatorBase<span style="color:rgb(180,180,180)">::*)(</span>size_t<span style="color:rgb(180,180,180)">,</span> size_t<span style="color:rgb(180,180,180)">)>(</span>
                      <span style="color:rgb(180,180,180)">&</span>AllocatorBase<span style="color:rgb(180,180,180)">::</span>Allocate<span style="color:rgb(180,180,180)">)</span> <span style="color:rgb(180,180,180)">!=</span>
                      <span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*(</span>DerivedT<span style="color:rgb(180,180,180)">::*)(</span>size_t<span style="color:rgb(180,180,180)">,</span> size_t<span style="color:rgb(180,180,180)">)>(</span>
                          <span style="color:rgb(180,180,180)">&</span>DerivedT<span style="color:rgb(180,180,180)">::</span>Allocate<span style="color:rgb(180,180,180)">),</span>
                  <span style="color:rgb(214,157,133)">"Class derives from AllocatorBase without implementing the "</span>
                  <span style="color:rgb(214,157,133)">"core Allocate(size_t, size_t) overload!"</span><span style="color:rgb(180,180,180)">);</span>
<span style="color:rgb(155,155,155)">#endif</span>
    <span style="color:rgb(86,156,214)">return</span> <span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">DerivedT</span> <span style="color:rgb(180,180,180)">*>(</span><span style="color:rgb(86,156,214)">this</span><span style="color:rgb(180,180,180)">)-></span>Allocate<span style="color:rgb(180,180,180)">(</span><span style="color:rgb(127,127,127)">Size</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(127,127,127)">Alignment</span><span style="color:rgb(180,180,180)">);</span>
  <span style="color:rgb(180,180,180)">}</span>
 
  <span style="color:darkgreen">/// \brief Deallocate \a Ptr to \a Size bytes of memory allocated by this</span>
  <span style="color:darkgreen">/// allocator.</span>
  <span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(200,200,200)">Deallocate</span><span style="color:rgb(180,180,180)">(</span><span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*</span><span style="color:rgb(127,127,127)">Ptr</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(78,201,176)">size_t</span> <span style="color:rgb(127,127,127)">Size</span><span style="color:rgb(180,180,180)">)</span> <span style="color:rgb(180,180,180)">{</span>
<span style="color:rgb(155,155,155)">#ifdef</span> __clang__
    <span style="color:rgb(86,156,214)">static_assert</span><span style="color:rgb(180,180,180)">(</span><span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">(</span>AllocatorBase<span style="color:rgb(180,180,180)">::*)(</span><span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*,</span> size_t<span style="color:rgb(180,180,180)">)>(</span>
                      <span style="color:rgb(180,180,180)">&</span>AllocatorBase<span style="color:rgb(180,180,180)">::</span>Deallocate<span style="color:rgb(180,180,180)">)</span> <span style="color:rgb(180,180,180)">!=</span>
                      <span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">(</span>DerivedT<span style="color:rgb(180,180,180)">::*)(</span><span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(180,180,180)">*,</span> size_t<span style="color:rgb(180,180,180)">)>(</span>
                          <span style="color:rgb(180,180,180)">&</span>DerivedT<span style="color:rgb(180,180,180)">::</span>Deallocate<span style="color:rgb(180,180,180)">),</span>
                  <span style="color:rgb(214,157,133)">"Class derives from AllocatorBase without implementing the "</span>
                  <span style="color:rgb(214,157,133)">"core Deallocate(void *) overload!"</span><span style="color:rgb(180,180,180)">);</span>
<span style="color:rgb(155,155,155)">#endif</span>
    <span style="color:rgb(86,156,214)">return</span> <span style="color:rgb(86,156,214)">static_cast</span><span style="color:rgb(180,180,180)"><</span><span style="color:rgb(78,201,176)">DerivedT</span> <span style="color:rgb(180,180,180)">*>(</span><span style="color:rgb(86,156,214)">this</span><span style="color:rgb(180,180,180)">)-></span>Deallocate<span style="color:rgb(180,180,180)">(</span><span style="color:rgb(127,127,127)">Ptr</span><span style="color:rgb(180,180,180)">,</span> <span style="color:rgb(127,127,127)">Size</span><span style="color:rgb(180,180,180)">);</span>
  <span style="color:rgb(180,180,180)">}</span></font><font face="Consolas">
</font></pre></div><div><div><br></div><div><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><span style="font-size:12.8px">Sincerely,</span><br style="font-size:12.8px"><span style="font-size:12.8px">Alexander Riccio</span><br style="font-size:12.8px"><span style="font-size:12.8px">--</span><br style="font-size:12.8px"><span style="font-size:12.8px">"Change the world or go home."</span><div style="font-size:12.8px"><a href="http://about.me/ariccio" target="_blank">about.me/ariccio</a></div><div style="font-size:12.8px"><a href="http://about.me/ariccio" target="_blank"><br></a></div><div style="font-size:12.8px">If left to my own devices, I will build more.</div><div style="font-size:12.8px">⁂</div></div></div></div></div></div>
</div></div></div></div>
<br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div></div>