[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-06-11 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

--- Comment #6 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Marek Polacek
:

https://gcc.gnu.org/g:ae275b986b8cc747a5b4f389cb05a71fdee1f886

commit r10-8280-gae275b986b8cc747a5b4f389cb05a71fdee1f886
Author: Marek Polacek 
Date:   Thu Jun 11 16:33:13 2020 -0400

c++: explicit(bool) malfunction with dependent expression [PR95066]

I forgot to set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P when merging two
function declarations and as a sad consequence, we never tsubsted
the dependent explicit-specifier in tsubst_function_decl, leading to
disregarding the explicit-specifier altogether, and wrongly accepting
this test.

PR c++/95066
* decl.c (duplicate_decls): Set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P.

* g++.dg/cpp2a/explicit16.C: New test.

[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-06-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #7 from Marek Polacek  ---
Fixed.

[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-05-13 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:661232da72d29f8f2385d5f588727beb74360144

commit r11-371-g661232da72d29f8f2385d5f588727beb74360144
Author: Marek Polacek 
Date:   Mon May 11 18:28:19 2020 -0400

c++: explicit(bool) malfunction with dependent expression [PR95066]

I forgot to set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P when merging two
function declarations and as a sad consequence, we never tsubsted
the dependent explicit-specifier in tsubst_function_decl, leading to
disregarding the explicit-specifier altogether, and wrongly accepting
this test.

PR c++/95066
* decl.c (duplicate_decls): Set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P.

* g++.dg/cpp2a/explicit16.C: New test.

[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-05-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #4 from Marek Polacek  ---
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545565.html

[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-05-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

--- Comment #3 from Marek Polacek  ---
Reduced:

template 
struct Foo {
  template 
  explicit(static_cast(true)) operator Foo();
};

template 
template 
Foo::operator Foo() {
  return {};
}

int
main ()
{
  Foo a;
  Foo b = a;
}

[Bug c++/95066] [C++ 20] Incorrect successful compilation with a conditional explicit

2020-05-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95066

Marek Polacek  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2020-05-11
   Keywords||accepts-invalid
 Ever confirmed|0   |1
 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
Thanks for the report.  In the first case we don't seem to ever substitute the
explicit-specifier.  I think we forget to lookup the explicit-specifier when
instantiating the out-of-line definition of operator Foo.

Since I've implemented explicit(bool), mine.