fix: compiler warnings with no side effects#2933
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e924d5f to
70c8446
Compare
2bd0c46 to
3cbd6c1
Compare
c9b4c32 to
da5c07f
Compare
3cbd6c1 to
35ac9e8
Compare
da5c07f to
ab7b139
Compare
35ac9e8 to
a634fdc
Compare
| #ifdef USING_CREG | ||
| // creg_class specializations are defined in type2.cpp via CR_BIND_TEMPLATE | ||
| template<> creg::Class type2<int32_t>::creg_class; | ||
| template<> creg::Class type2<float>::creg_class; |
There was a problem hiding this comment.
what was the issue when these were missing?
There was a problem hiding this comment.
oh sorry, here's the warning (one per instantiated type):
rts/System/type2.h:12:2: warning: instantiation of variable 'type2<int>::creg_class' required here,
but no definition is available [-Wundefined-var-template]
12 | CR_DECLARE_STRUCT(type2)
| ^
rts/System/creg/creg.h:244:33: note: expanded from macro 'CR_DECLARE_STRUCT'
rts/System/creg/creg.h:216:46: note: expanded from macro 'CR_DECLARE_BASE'
216 | static creg::Class* StaticClass() { return &creg_class; } \
probe.cpp:2:39: note: in instantiation of member function 'type2<int>::StaticClass' requested here
rts/System/type2.h:12:2: note: forward declaration of template entity is here
rts/System/creg/creg.h:213:21: note: expanded from macro 'CR_DECLARE_BASE'
213 | static creg::Class creg_class; \
rts/System/type2.h:12:2: note: add an explicit instantiation declaration to suppress this warning
if 'type2<int>::creg_class' is explicitly instantiated in another translation unit
just telling the compiler explicitly not to worry about generating these, as they're hand-written elsewhere. I think it's a limitation of compilation seeing only one file at a time, but then these resolve at linking time.
There was a problem hiding this comment.
Perhaps this should live in creg_cond.h then?
There was a problem hiding this comment.
Hm. Looking at cred_cond.h it's all type-agnostic creg plumbing, like its all macro definitions. Does it really make sense to put type2 stuff in there? Kinda inverts the dependency.
if you mean just factoring out the #ifdef USING_CREG we could write a helper macro in creg_cond.h that is something like #define CR_DECLARE_TEMPLATE_INSTANCE(TCls) template<> creg::Class TCls::creg_class
then in this type2 file you just use the macro:
CR_DECLARE_TEMPLATE_INSTANCE(int2)
CR_DECLARE_TEMPLATE_INSTANCE(float2)
...
wdyt?
There was a problem hiding this comment.
something like
#define CR_DECLARE_TEMPLATE_INSTANCE(TCls) template<> creg::Class TCls::creg_class
Sounds alright.
There was a problem hiding this comment.
should be good now :)
a634fdc to
6ddbfda
Compare

Purpose
Fix the warning spam when compiling with clang, gcc, or msvc (mostly clang). This PR focuses on the non-behaviour changing fixes to code, mostly formatting changes or implicit casts.
AI Disclosure
This PR was generated through running claude code in a loop to fix every warning. However, every non-trivial change was inspected and several "fixes" were dropped in favor of different solutions to try and keep backwards compatibility in mind. I've called out the couple places where I don't understand the fix or the implication of the fix to other reviewers.