[Bug c++/105806] New: [concepts] template class specialization using concept issue
josephcanedo at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 1 18:40:31 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105806
Bug ID: 105806
Summary: [concepts] template class specialization using concept
issue
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: josephcanedo at hotmail dot com
Target Milestone: ---
We have a simple "trait" template class defining a static function holding a
static variable.
struct meta {};
template <typename T>
struct type_traits
{
static meta& get_meta() {
static meta m;
return m;
}
};
This is used in several .hpp files among several TUs, without any problems.
We are attempting to use concepts to make specialisations of these type_traits,
e.g.
class root_base {};
template <typename T>
concept root_type = std::is_base_of_v<root_base, T>;
template <typename>
struct type_traits;
template <root_type Root>
struct type_traits<Root>
{
static meta& get_meta() {
static meta m;
return m;
}
};
Using these compiles all fine, but we notice that for a given type_traits
instantiation with some type, we have several instances of get_meta() functions
symbols and hence several meta m variables, which we believe is not expected.
ie for given
class A: root_base {};
We have N type_traits<A>::get_meta() functions symbols (different addresses for
these functions).
This only occurs with -O1 or higher option. -O0 does not exhibit this behavior.
More information about the Gcc-bugs
mailing list