public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected
@ 2020-05-27 17:38 mpolacek at gcc dot gnu.org
  2020-05-27 17:41 ` [Bug c++/95369] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-27 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95369
           Summary: braced-init-list with designated initializers as
                    template-argument rejected
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

struct S {
  unsigned a;
  unsigned b;
#ifdef CTOR
  constexpr S(unsigned _a, unsigned _b) noexcept: a{_a}, b{_b} { }
#endif
};

template <S p>
void fnc()
{
}

template<S s> struct X { };

void f()
{
  fnc<{.a = 10, .b = 20}>();
  X<{.a = 1, .b = 2}> x;
}

If CTOR is not defined, we reject, but if it is defined, we accept.  We should
probably reverse this behavior.  We should accept the aggregate initialization,
but with CTOR, S is no longer an aggregate (it has a user-declared or inherited
constructor).

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
@ 2020-05-27 17:41 ` mpolacek at gcc dot gnu.org
  2020-05-27 18:40 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-27 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is accepted fine (as it should be):

struct S {
  int a;
  int b;
};

int
main ()
{
  S s{.a = 1, .b = 2};
}

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
  2020-05-27 17:41 ` [Bug c++/95369] " mpolacek at gcc dot gnu.org
@ 2020-05-27 18:40 ` mpolacek at gcc dot gnu.org
  2020-05-27 19:17 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-27 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is not really about designated initializers; we wrongly reject this one
too:

struct S {
  unsigned a;
  unsigned b;
};

template<S s> struct X { };

void f()
{
  X<{ 1u, 2u }> x;
}

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
  2020-05-27 17:41 ` [Bug c++/95369] " mpolacek at gcc dot gnu.org
  2020-05-27 18:40 ` mpolacek at gcc dot gnu.org
@ 2020-05-27 19:17 ` mpolacek at gcc dot gnu.org
  2020-05-28 20:45 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-27 19:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think the problem is that we never called digest_init prior calling
convert_nontype_argument.

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-05-27 19:17 ` mpolacek at gcc dot gnu.org
@ 2020-05-28 20:45 ` mpolacek at gcc dot gnu.org
  2020-06-05 19:51 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-28 20:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-05-28
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think I have a patch.

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-05-28 20:45 ` mpolacek at gcc dot gnu.org
@ 2020-06-05 19:51 ` cvs-commit at gcc dot gnu.org
  2020-06-16 17:21 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-05 19:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r11-1010-gcecc73af4980004502f4c327b6c639125defb379
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Jun 5 14:22:35 2020 -0400

    c++: Make braced-init-list as template arg work with aggr init [PR95369]

    Barry pointed out to me that our braced-init-list as a template-argument
    extension doesn't work as expected when we aggregate-initialize.  Since
    aggregate list-initialization is a user-defined conversion sequence, we
    allow it as part of a converted constant expression.

    Co-authored-by: Jason Merrill <jason@redhat.com>

    gcc/cp/ChangeLog:

            PR c++/95369
            * call.c (build_converted_constant_expr_internal): Allow
            list-initialization.

    gcc/testsuite/ChangeLog:

            PR c++/95369
            * g++.dg/cpp2a/nontype-class38.C: New test.

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-06-05 19:51 ` cvs-commit at gcc dot gnu.org
@ 2020-06-16 17:21 ` cvs-commit at gcc dot gnu.org
  2020-06-16 17:23 ` mpolacek at gcc dot gnu.org
  2021-07-27 22:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-16 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:04afaf4575ff239279cfa34aff17101345451965

commit r11-1392-g04afaf4575ff239279cfa34aff17101345451965
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jun 15 15:31:32 2020 -0400

    c++: Don't allow designated initializers with non-aggregates [PR95369]

    Another part of 95369 is that we accept designated initializers with
    non-aggregate types.  That seems to be wrong since they're part of
    aggregate initialization.  clang/icc also reject it.

    There are multiple contexts where we can use designated initializers:
    function-like casts, member list initializers, NTTP, etc.  I've adjusted
    add_list_candidates and implicit_conversion_error in order to to detect
    this case.

    gcc/cp/ChangeLog:

            PR c++/95369
            * call.c (add_list_candidates): Return if a designated initializer
            is used with a non-aggregate.
            (implicit_conversion_error): Give an error for the case above.

    gcc/testsuite/ChangeLog:

            PR c++/95369
            * g++.dg/cpp2a/desig11.C: Adjust dg-error.
            * g++.dg/cpp2a/desig16.C: New test.

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-06-16 17:21 ` cvs-commit at gcc dot gnu.org
@ 2020-06-16 17:23 ` mpolacek at gcc dot gnu.org
  2021-07-27 22:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-16 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This should now work as expected.

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

* [Bug c++/95369] braced-init-list with designated initializers as template-argument rejected
  2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2020-06-16 17:23 ` mpolacek at gcc dot gnu.org
@ 2021-07-27 22:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

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

end of thread, other threads:[~2021-07-27 22:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 17:38 [Bug c++/95369] New: braced-init-list with designated initializers as template-argument rejected mpolacek at gcc dot gnu.org
2020-05-27 17:41 ` [Bug c++/95369] " mpolacek at gcc dot gnu.org
2020-05-27 18:40 ` mpolacek at gcc dot gnu.org
2020-05-27 19:17 ` mpolacek at gcc dot gnu.org
2020-05-28 20:45 ` mpolacek at gcc dot gnu.org
2020-06-05 19:51 ` cvs-commit at gcc dot gnu.org
2020-06-16 17:21 ` cvs-commit at gcc dot gnu.org
2020-06-16 17:23 ` mpolacek at gcc dot gnu.org
2021-07-27 22:13 ` 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).