[Bug c++/67225] [concepts] Expression constraint with a constrained result turns off access checking
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Apr 29 19:19:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67225
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-04-29
Ever confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Testcase from 85555
/*
* Uncommenting the following line and commenting the line after that
* makes the program fail to compile (as it should).
*/
//template<typename Target>
template<typename Target, typename... Ts>
concept bool has_resize ()
{
return requires (Target tgt)
{
{ tgt.resize () };
};
};
template<typename Target>
void resize (Target tgt)
{
if constexpr (has_resize<Target> ())
{
tgt.resize ();
}
}
class MyClass
{
private:
int foo (int i)
{
return i * 2;
}
};
int main ()
{
return MyClass {}.foo (7);
}
More information about the Gcc-bugs
mailing list