From b98ef824450d2897f5ea8f5254d614e6f8148d33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Rheinl=C3=A4nder?= Date: Wed, 16 Feb 2022 23:57:36 +0100 Subject: [PATCH] Work around a compiler bug on MSVC. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The two 'reg_info' declarations introduced in f271f67d2f turned out to confuse MSVC: It thinks that these declarations are definitions and then complains about a missing default ctor (error C2512) and about duplicate definitions later in the .cpp files (error C2766). But the standard says in [temp.expl.spec] §13: An explicit specialization of a static data member of a template or an explicit specialization of a static data member template is a definition if the declaration includes an initializer; otherwise, it is a declaration. [Note: The definition of a static data member of a template that requires default-initialization must use a braced-init- list: template<> X Q::x; // declaration template<> X Q::x (); // error: declares a function template<> X Q::x { }; // definition --end note] There is no initializer at lst.h:35 and at exprseq.h:35. Hence, this is merely a declaration and the compiler's error message is wrong. Let's work around by #ifndef'ing the two lines for silly MSVC. --- ginac/exprseq.h | 2 ++ ginac/lst.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ginac/exprseq.h b/ginac/exprseq.h index dea1e38e..ce78aae9 100644 --- a/ginac/exprseq.h +++ b/ginac/exprseq.h @@ -32,7 +32,9 @@ namespace GiNaC { typedef container exprseq; /** Declaration of container::reg_info for exprseq. */ +#ifndef _MSC_VER // workaround error C2766: explicit specialization; 'reg_info' has already been defined template<> registered_class_info exprseq::reg_info; +#endif // defined in exprseq.cpp template<> bool exprseq::info(unsigned inf) const; diff --git a/ginac/lst.h b/ginac/lst.h index 6b047c69..1dae29ee 100644 --- a/ginac/lst.h +++ b/ginac/lst.h @@ -32,7 +32,9 @@ namespace GiNaC { typedef container lst; /** Declaration of container::reg_info for lst. */ +#ifndef _MSC_VER // workaround error C2766: explicit specialization; 'reg_info' has already been defined template<> registered_class_info lst::reg_info; +#endif /** Specialization of container::get_default_flags() for lst. */ template<> inline unsigned lst::get_default_flags() { return status_flags::not_shareable; } -- 2.45.1