[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #8 from Jakub Jelinek  ---
Fixed for 11.3+ now too.

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #7 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:6f61195e0433f907e5aa1a16f02d4106503d3351

commit r11-8997-g6f61195e0433f907e5aa1a16f02d4106503d3351
Author: Jakub Jelinek 
Date:   Tue Sep 14 16:55:04 2021 +0200

c++: Fix __is_*constructible/assignable for templates [PR102305]

is_xible_helper returns error_mark_node (i.e. false from the traits)
for abstract classes by testing ABSTRACT_CLASS_TYPE_P (to) early.
Unfortunately, as the testcase shows, that doesn't work on class templates
that haven't been instantiated yet, ABSTRACT_CLASS_TYPE_P for them is false
until it is instantiated, which is done when the routine later constructs
a dummy object with that type.

The following patch fixes this by calling complete_type first, so that
ABSTRACT_CLASS_TYPE_P test will work properly, while keeping the handling
of arrays with unknown bounds, or incomplete types where it is done
currently.

2021-09-14  Jakub Jelinek  

PR c++/102305
* method.c (is_xible_helper): Call complete_type on to.

* g++.dg/cpp0x/pr102305.C: New test.

(cherry picked from commit f008fd3a480e3718436156697ebe7eeb47841457)

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-14 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #6 from Jonathan Wakely  ---
It should be backported IMHO.

I don't see how anybody can be relying on is_default_constructible being wrong,
that doesn't make much sense. You check that trait in SFINAE contexts to see if
you can construct the type, but because the answer is wrong any code that tries
to construct it will get a compiler error.

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #5 from Jakub Jelinek  ---
On one side, some code could be relying on bug compatibility and so it would be
undesirable to change it on release branches, on the other side the current
behavior there is just weird,
#include 

template  struct AbstractTemplate {
  virtual ~AbstractTemplate() = 0;
};

#ifdef D
struct S : AbstractTemplate {};
#endif
bool a = std::is_default_constructible >::value;

a is true if D is not defined and false if D is defined.  And one can't really
construct those abstract template classes...

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #4 from Jakub Jelinek  ---
Fixed for 12.0 so far.
Do we want to backport it?

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-14 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #3 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

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

commit r12-3525-gf008fd3a480e3718436156697ebe7eeb47841457
Author: Jakub Jelinek 
Date:   Tue Sep 14 16:55:04 2021 +0200

c++: Fix __is_*constructible/assignable for templates [PR102305]

is_xible_helper returns error_mark_node (i.e. false from the traits)
for abstract classes by testing ABSTRACT_CLASS_TYPE_P (to) early.
Unfortunately, as the testcase shows, that doesn't work on class templates
that haven't been instantiated yet, ABSTRACT_CLASS_TYPE_P for them is false
until it is instantiated, which is done when the routine later constructs
a dummy object with that type.

The following patch fixes this by calling complete_type first, so that
ABSTRACT_CLASS_TYPE_P test will work properly, while keeping the handling
of arrays with unknown bounds, or incomplete types where it is done
currently.

2021-09-14  Jakub Jelinek  

PR c++/102305
* method.c (is_xible_helper): Call complete_type on to.

* g++.dg/cpp0x/pr102305.C: New test.

[Bug c++/102305] intrinsic __is_constructible is wrong for templated abstract classes

2021-09-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102305

--- Comment #2 from Jonathan Wakely  ---
Thanks, Jakub!

Although this is a component=c++ bug, it also results in a libstdc++
regression, because we've been giving the wrong answer since starting to use
the intrinsic (e.g. std::is_default_constructible started to use it in GCC
9.2).