[Bug c++/104141] nested requires statement causes access to private member function

2022-01-21 Thread fchelnokov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

--- Comment #6 from Fedor Chelnokov  ---
I agree that Clang behavior here might be wrong. Submitted
https://github.com/llvm/llvm-project/issues/53334

[Bug c++/104141] nested requires statement causes access to private member function

2022-01-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

--- Comment #5 from Andrew Pinski  ---
(In reply to Fedor Chelnokov from comment #4)
> A::f() does not depend on template parameter, so the rules here are somewhat
> different than in T::f(). A possible answer:
> https://stackoverflow.com/a/70783451/7325599

But clang is not rejecting it the following:

class A{
   static void f();
};
template  concept t =  requires{ A::f(); };
static_assert( !t );

By saying A::f() is private even, it literally sets the concept to false and
nothing else which is really really shocking.

[Bug c++/104141] nested requires statement causes access to private member function

2022-01-21 Thread fchelnokov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

--- Comment #4 from Fedor Chelnokov  ---
In
```
template  concept t =  requires{ A::f(); };
```
A::f() does not depend on template parameter, so the rules here are somewhat
different than in T::f(). A possible answer:
https://stackoverflow.com/a/70783451/7325599

[Bug c++/104141] nested requires statement causes access to private member function

2022-01-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

--- Comment #3 from Andrew Pinski  ---
Looks like clang does not always do access checking for static functions calls
inside requires. I know GCC has a bug there for dealing with caching in the
wrong context (I don't have the bug #).

[Bug c++/104141] nested requires statement causes access to private member function

2022-01-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

--- Comment #2 from Andrew Pinski  ---
Note clang fails the static_assert with this one but that does not make sense
at all:
class A{
   static void f();
};
template  concept t =  requires{ A::f(); };
static_assert( !t );

[Bug c++/104141] nested requires statement causes access to private member function

2022-01-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104141

Andrew Pinski  changed:

   What|Removed |Added

Summary|Access to private member|nested requires statement
   |function from   |causes access to private
   |requires-clause accepted|member function

--- Comment #1 from Andrew Pinski  ---
I am not 100% up to speed on requires statment here but I would assume the
outer requires would cause the inner requires to be slient on access
violations.
E.g the following is accepted without error even:
class A{
   static void f();
};
template  concept t =  requires{ T::f(); };
static_assert( !t );
-- CUT 
Likewise of this one where we don't have a depdent requires even (clang rejects
it but GCC/MSVC accept it):
class A{
   static void f();
};
template  constexpr bool t =  requires{ A::f(); };
static_assert( !t );
-- CUT 
But GCC fails with this one but if the above is valid I don't see why the below
is not either:

class A{
   static void f();
};
static_assert( !requires{ A::f(); } );