[Bug c++/105606] New: [12 Regression] std::pair with nested struct and NSDMI

mrjoel at lixil dot net gcc-bugzilla@gcc.gnu.org
Sun May 15 05:35:02 GMT 2022


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

            Bug ID: 105606
           Summary: [12 Regression] std::pair with nested struct and NSDMI
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrjoel at lixil dot net
  Target Milestone: ---

The following snippets fail to compile with GCC 12.1.0. The first relates more
to actual code usage while the second I believe to be a more minimal
reproducer.

This looks closely related to the examples and discussion in bug 96645 and yet
this case compiles in versions through 11, only failing to compile in 12.

It may also be closely related to (or have it as an underlying cause) bug
102199.

Snippet 1
=========

#include <map>
#include <utility>

struct Outer {
    struct Inner {
        int a{0};
    };

    std::pair<Inner, int> p;

    void f() {
        std::map<int, std::pair<Inner, int>> m;
        m[0] = p;
    }
};

Snippet 2
=========

#include <utility>

struct Outer {
    struct Inner {
        int a{0}; // removing initialization compiles
    };

    std::pair<Inner, int> p; // commenting out compiles
    void f() {
        [[maybe_unused]] std::pair<Inner, int> localp;
    }
};


More information about the Gcc-bugs mailing list