This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64352] New: [5.0 regression] No SFINAE with deleted function


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

            Bug ID: 64352
           Summary: [5.0 regression] No SFINAE with deleted function
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr

Created attachment 34300
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34300&action=edit
Minimal testcase

Using:
g++-trunk (GCC) 5.0.0 20141218 (experimental)

Testcase:

template<bool B> struct bool_type
{ static constexpr bool value = B; };

using true_type = bool_type<true>;
using false_type = bool_type<false>;

template<typename T> T&& declval();

template<typename...> struct void_ { using type = void; };
template<typename... I> using void_t = typename void_<I...>::type;

template<typename _Tp, typename = void>
struct _Has_addressof_free: false_type { };

template<typename _Tp>
struct _Has_addressof_free
<_Tp, void_t<decltype( operator&(declval<const _Tp&>()) )>>
: true_type { };

struct foo {};
void operator&(foo) = delete;

int main()
{
    static_assert( !_Has_addressof_free<int>::value, "" );
    // error: use of deleted function 'void operator&(foo)'
    static_assert( _Has_addressof_free<foo>::value, "" );
}

This produces the following:

$ g++-trunk -std=c++11 main.cpp 
main.cpp: In function 'int main()':
main.cpp:17:33: error: use of deleted function 'void operator&(foo)'
 <_Tp, void_t<decltype( operator&(declval<const _Tp&>()) )>>
                                 ^
main.cpp:21:6: note: declared here
 void operator&(foo) = delete;
      ^
main.cpp:27:5: error: static assertion failed: 
     static_assert( _Has_addressof_free<foo>::value, "" );
     ^

I'm not entirely sure this is a regression, e.g. libstdc++'s
testsuite/experimental/optional/observers/2.cc is very similar
but passes. I'm working on experimental/optional however and
I ended up tripping over this, and I didn't touch the
_Has_addressof_* stuff. It is copied (almost) verbatim here,
but not the declval/true_type/false_type/[__]void[_t] bits,
in case that's of any help.

Changing the deleted definition with e.g. a dummy definition
('{}') makes the program compiles as expected.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]