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

            Bug ID: 69387
           Summary: undefined reference to constant in template
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

Hi,

the following example is miss-compiled at -O0

cat test.cc
class StatusCode
{
public:
  static const int TEST_VALUE = 0x2;
};

typedef bool AssertionResult;

template <typename T1, typename T2>
AssertionResult CmpHelperEQ(const T1& expected,
                            const T2& actual)
{
  if (expected == actual)
    return true;

  return false;
}

int
main()
{
  return CmpHelperEQ(2, StatusCode::TEST_VALUE) ? 0 : 1;
}
gcc test.cc
test.cc:(.text+0x14): undefined reference to `StatusCode::TEST_VALUE'
collect2: error: ld returned 1 exit status

Reply via email to