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

            Bug ID: 116077
           Summary: GCC hasn't implemented CWG DR 2387
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

CWG 2387 (https://cplusplus.github.io/CWG/issues/2387.html), which makes const
variable templates has external linkage by default, is not implemented by GCC
yet.

As shown in https://wandbox.org/permlink/bVfvGTlfwJ9IQll7 (switch to Clang to
see the correct results):

common.h:
```
template<typename>
constexpr int non_inline{};

template<typename>
inline constexpr int inlined{};
```

other.cpp
```
#include "common.h"
#include <iostream>

void other_inlined()
{
    std::cout << "    other: " << &inlined<int> << '\n';
}

void other_non_inline()
{
    std::cout << "    other: " << &non_inline<int> << '\n';
}
```

main.cpp
```
#include "common.h"
#include <iostream>

void other_inlined();
void other_non_inline();

int main()
{
    std::cout << "non-inline:\n";
    std::cout << "    main:  " << &non_inline<int> << '\n';
    other_non_inline();

    std::cout << "inlined:\n";
    std::cout << "    main:  " << &inlined<int> << '\n';
    other_inlined();
}
```

Reply via email to