Skip to content

modernize-use-designated-initializers reported for pre-C++20 code #83732

Closed
@firewave

Description

@firewave
struct S
{
    int i1;
    int i2;
};

void f()
{
    S s{0};
}

Running with -std=c++11 produces the following warning:

<source>:9:8: warning: use designated initializer list to initialize 'S' [modernize-use-designated-initializers]
    9 |     S s{0};
      |        ^~~
      |         .i1=
<source>:1:1: note: aggregate type is defined here
    1 | struct S
      | ^

https://godbolt.org/z/EzerEWsKh

Designated initializers are not available until C++20: https://en.cppreference.com/w/cpp/language/aggregate_initialization.

CC @SimplyDanny @PiotrZSL

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions