public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument
@ 2022-08-15 16:05 jlame646 at gmail dot com
  2022-08-15 16:20 ` [Bug c++/106629] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jlame646 at gmail dot com @ 2022-08-15 16:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106629

            Bug ID: 106629
           Summary: GCC accepts invalid program involving {1,2,3,4} as
                    template argument
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following invalid program is accepted by gcc.
https://godbolt.org/z/Mb3qbvvPz 

```
struct Impl
{
  constexpr Impl(std::initializer_list<int>)
  {

  }
};
struct Bar{};
template<typename T, Impl impl>
struct Foo
{

};
int main()
{
    constexpr Foo<Bar, {1,2,3,4}> foo; //works in msvc & gcc but rejected in
clang
    return 0;
}
```

The program is invalid because `{1,2,3,4}` cannot be a template argument.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106629] GCC accepts invalid program involving {1,2,3,4} as template argument
  2022-08-15 16:05 [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument jlame646 at gmail dot com
@ 2022-08-15 16:20 ` pinskia at gcc dot gnu.org
  2022-08-15 16:33 ` 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-08-15 16:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106629

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 53462
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53462&action=edit
full testcase

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106629] GCC accepts invalid program involving {1,2,3,4} as template argument
  2022-08-15 16:05 [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument jlame646 at gmail dot com
  2022-08-15 16:20 ` [Bug c++/106629] " pinskia at gcc dot gnu.org
@ 2022-08-15 16:33 ` pinskia at gcc dot gnu.org
  2022-08-15 16:35 ` mpolacek at gcc dot gnu.org
  2022-08-15 16:49 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-15 16:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106629

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-08-15
           Keywords|                            |accepts-invalid

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>The program is invalid because `{1,2,3,4}` cannot be a template argument.

This is because braced-init-list is not included in constant-expression .

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106629] GCC accepts invalid program involving {1,2,3,4} as template argument
  2022-08-15 16:05 [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument jlame646 at gmail dot com
  2022-08-15 16:20 ` [Bug c++/106629] " pinskia at gcc dot gnu.org
  2022-08-15 16:33 ` pinskia at gcc dot gnu.org
@ 2022-08-15 16:35 ` mpolacek at gcc dot gnu.org
  2022-08-15 16:49 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-08-15 16:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106629

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Not a bug, this is
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2450 I implemented
in GCC.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106629] GCC accepts invalid program involving {1,2,3,4} as template argument
  2022-08-15 16:05 [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument jlame646 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-08-15 16:35 ` mpolacek at gcc dot gnu.org
@ 2022-08-15 16:49 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-15 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106629

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #3)
> Not a bug, this is
> https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2450 I
> implemented in GCC.

Oh I see, I should have looked into the active defect reports too :).

Even though cppreference is not part of the C++ standard. It would be useful to
put a reference to that defect report on
https://en.cppreference.com/w/cpp/language/template_parameters .

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-15 16:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 16:05 [Bug c++/106629] New: GCC accepts invalid program involving {1,2,3,4} as template argument jlame646 at gmail dot com
2022-08-15 16:20 ` [Bug c++/106629] " pinskia at gcc dot gnu.org
2022-08-15 16:33 ` pinskia at gcc dot gnu.org
2022-08-15 16:35 ` mpolacek at gcc dot gnu.org
2022-08-15 16:49 ` 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).