public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable @ 2022-12-27 13:54 jlame646 at gmail dot com 2022-12-28 19:22 ` [Bug c++/108234] " pinskia at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: jlame646 at gmail dot com @ 2022-12-27 13:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108234 Bug ID: 108234 Summary: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlame646 at gmail dot com Target Milestone: --- GCC trunk accepts the following invalid program: https://godbolt.org/z/h5q7589Tr ``` template <int&> struct X{}; template <auto V> int func(X<V>) { return 1; } int i; int main() { return func(X<i>{}); } ``` Clang rejects the above program while gcc and msvc accepts it. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/108234] GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable 2022-12-27 13:54 [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable jlame646 at gmail dot com @ 2022-12-28 19:22 ` pinskia at gcc dot gnu.org 2022-12-28 19:35 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-28 19:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108234 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- If I change func to: template <auto &V> int func(X<V>) { return 1; } And then clang accepts it. The question becomes what can be deduced as the type of V. Here is a slightly different testcase: ``` template <int&> struct X{}; template <typename T> void ff(){}; template <typename T, T V> int func(X<V>) { return 1; } int i; int main() { return func(X<i>{}); } ``` Note GCC rejects the above testcase for C++14 but accepts it for C++17. So I am not 100% this is invalid and clang just does not implement some rule of C++17 correctly dealing with reference types ... ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/108234] GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable 2022-12-27 13:54 [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable jlame646 at gmail dot com 2022-12-28 19:22 ` [Bug c++/108234] " pinskia at gcc dot gnu.org @ 2022-12-28 19:35 ` pinskia at gcc dot gnu.org 2022-12-28 19:37 ` pinskia at gcc dot gnu.org 2022-12-28 19:38 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-28 19:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108234 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r2.html Looks like clang does not implement this paper correctly for reference types ... Modified testcase from that paper using reference types, C++17 should reject this while c++14 will accept it: template <const int &N> struct A; template <typename T, T N> int foo(A<N> *) = delete; void foo(void *); constexpr int t = 1; void bar(A<t> *p) { foo(p); // ill-formed; previously well-formed } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/108234] GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable 2022-12-27 13:54 [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable jlame646 at gmail dot com 2022-12-28 19:22 ` [Bug c++/108234] " pinskia at gcc dot gnu.org 2022-12-28 19:35 ` pinskia at gcc dot gnu.org @ 2022-12-28 19:37 ` pinskia at gcc dot gnu.org 2022-12-28 19:38 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-28 19:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108234 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://github.com/llvm/llv | |m-project/issues/40328 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- See: https://github.com/llvm/llvm-project/issues/40328 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/108234] GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable 2022-12-27 13:54 [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable jlame646 at gmail dot com ` (2 preceding siblings ...) 2022-12-28 19:37 ` pinskia at gcc dot gnu.org @ 2022-12-28 19:38 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-28 19:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108234 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://github.com/llvm/llv | |m-project/issues/38721 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Also: https://github.com/llvm/llvm-project/issues/38721 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-28 19:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-27 13:54 [Bug c++/108234] New: GCC accepts invalid program involving nontype template parameter of auto with non constexpr variable jlame646 at gmail dot com 2022-12-28 19:22 ` [Bug c++/108234] " pinskia at gcc dot gnu.org 2022-12-28 19:35 ` pinskia at gcc dot gnu.org 2022-12-28 19:37 ` pinskia at gcc dot gnu.org 2022-12-28 19:38 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).