[Bug c++/90080] [8 Regression] SFINAE failure with static_cast

2019-04-16 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90080

Jonathan Wakely  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #2 from Jonathan Wakely  ---
Reduced:

struct false_type { static constexpr bool value = false; };
struct true_type { static constexpr bool value = true; };
template struct enable_if { };
template struct enable_if { using type = T; };
template T&& declval();

template
struct is_static_castable : false_type
{};

template
struct is_static_castable(declval()))> :
true_type
{};

template::value, int>::type = 0>
To* safePtrCast(From* from)
{
return static_cast(from);
}

template::value, int>::type = 0>
To* safePtrCast(From* from)
{
return dynamic_cast(from);
}

struct BarBase{ virtual ~BarBase() = default;};
struct Bar : virtual BarBase{};

Bar* foo(BarBase* b){
return safePtrCast(b);
}

This started to fail with r258824:

PR c++/78489 - wrong SFINAE behavior.

PR c++/84489
* pt.c (type_unification_real): Don't defer substitution failure.

And was fixed on trunk by r269921:

PR c++/87748 - substitution failure error with decltype.

This issue is similar to PR 87480; in both cases we were doing
non-dependent
substitution with processing_template_decl set, leading to member access
expressions seeming still instantiation-dependent, and therefore decltype
not being simplified to its actual type.  And as in that PR, the fix is to
clear processing_template_decl while substituting a default template
argument.

* pt.c (most_specialized_partial_spec): Clear
processing_template_decl.

So this looks like a dup of that PR, which is still present on gcc-8-branch.

*** This bug has been marked as a duplicate of bug 87748 ***

[Bug c++/90080] [8 Regression] SFINAE failure with static_cast

2019-04-16 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90080

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-04-16
  Known to work||4.7.1, 7.4.0, 9.0
Summary|SFINAE failure with |[8 Regression] SFINAE
   |static_cast |failure with static_cast
 Ever confirmed|0   |1
  Known to fail||8.1.0, 8.2.0, 8.3.0

--- Comment #1 from Jonathan Wakely  ---
(In reply to Alex from comment #0)
> This looks like a regression as a similar error is described here
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44267

Agreed. It works with GCC 7 and with trunk, but not GCC 8.