Skip to content

Member functions of class templates not instantiated despite [[gnu::used]] #20297

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 19923
Version 3.4
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

In a class template, g++ instantiates member functions marked with [[gnu::used]] even when those functions are used nowhere in the program. clang does not. This causes code to compile that doesn't compile on g++, e.g.

#include <type_traits>

template<class I>
class X {
  [[gnu::used]]
  static void check() {
    static_assert(std::is_enum<I>::value, "");
  }
};

X<int> x;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:to-be-triagedShould not be used for new issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions