Re: [GiNaC-devel] Another MSVC error
Hi Richard,
Can you, please, try to explicitly delete the default ctors instead? Find a patch attached.
the patch leads to lst.h(35): error C2280: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': attempting to reference a deleted function class_info.h(48): note: see declaration of 'GiNaC::class_info<GiNaC::registered_class_options>::class_info' class_info.h(48): note: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': function was explicitly deleted exprseq.h(35): error C2280: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': attempting to reference a deleted function class_info.h(48): note: see declaration of 'GiNaC::class_info<GiNaC::registered_class_options>::class_info' class_info.h(48): note: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': function was explicitly deleted But since these two lines are exactly those two which we need to #ifdef away because of the C2766 error, both errors can be resolved by a simple patch: diff --git a/ginac/exprseq.h b/ginac/exprseq.h index dea1e38e..61a2527d 100644 --- a/ginac/exprseq.h +++ b/ginac/exprseq.h @@ -32,7 +32,10 @@namespace GiNaC { typedef container<std::vector> exprseq; /** Declaration of container::reg_info for exprseq. */ +#ifndef _MSC_VER +// Avoid exprseq.cpp(27): 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..415abd03 100644 --- a/ginac/lst.h +++ b/ginac/lst.h @@ -32,7 +32,10 @@namespace GiNaC { typedef container<std::list> lst; /** Declaration of container::reg_info for lst. */ +#ifndef _MSC_VER +// Avoid lst.cpp(28): 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; } This compiles and all checks pass. By the way, both declaration and definition in lst.h/cpp and exprseq.h/cpp seem to be superfluous, since even without them all tests also pass successfully... Jan
Hi Jan! On 16.02.22 21:24, Jan Rheinländer wrote:
lst.h(35): error C2280: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': attempting to reference a deleted function class_info.h(48): note: see declaration of 'GiNaC::class_info<GiNaC::registered_class_options>::class_info' class_info.h(48): note: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': function was explicitly deleted exprseq.h(35): error C2280: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': attempting to reference a deleted function class_info.h(48): note: see declaration of 'GiNaC::class_info<GiNaC::registered_class_options>::class_info' class_info.h(48): note: 'GiNaC::class_info<GiNaC::registered_class_options>::class_info(void)': function was explicitly deleted
Well, this confirms it: MSVC indeed tries to instantiate a registered_class_info at lst.h:35 and at exprseq.h:35. 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<int>::x; // declaration template<> X Q<int>::x (); // error: declares a function template<> X Q<int>::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. Moreover, since you have shown that the program works when a default ctor is provided, we can conclude that the constructed objects are never used, since class_info is not a plain old data type (it contains three pointers) - otherwise the program should crash. Sigh, I am going to apply this patch with a grudge. Thank you, Jan, for reporting this and for trying out the various patches!
By the way, both declaration and definition in lst.h/cpp and exprseq.h/cpp seem to be superfluous, since even without them all tests also pass successfully...
Oh, try compiling without them using CLang! We discussed this a year ago when patch f271f67d2f was pushed. The discussion can be found on the list archive. All my best, -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
participants (2)
-
Jan Rheinländer
-
Richard B. Kreckel