[Bug c++/86642] Spurious return type warning with enable_if<foo, void>

webrown.cpp at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 23 11:44:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86642

W E Brown <webrown.cpp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |webrown.cpp at gmail dot com

--- Comment #1 from W E Brown <webrown.cpp at gmail dot com> ---
I believe this issue is based on a minor misunderstanding.

As written, the return type is never a void type.  However, a small adjustment
in the return type gives what seems to be the intended effect:

  std::enable_if_t<true, void>  // assumes C++14 or later
or
  typename std::enable_if<true, void>::type  // any C++ dialect

Either will work to invoke the enable_if metafunction and produce a SFINAE
effect.  However, as written, the metafunction is not invoked and so does not
activate SFINAE. 

However, as written, the code says that func will return an object of this
metafunction's type; since the function does not do so, the warning seems
correct.  I respectfully recommend this issue be closed as INVALID.


More information about the Gcc-bugs mailing list