2 ms·
> I don't think that is clear Right. I missed that the uncalled function was public. So the issue is not clear until you link I suppose, so only detected "glob
by alkonaut 9y ago
> I don't think that is clear
Right. I missed that the uncalled function was public. So the issue is not clear until you link I suppose, so only detected "globally" whether the function is called. is it fair to say that that kind of global analysis is rare in the compiler+linker toolchain world for C, and usually left to static analyzers instead?
> The compiler can't tell from just analysing the one file shown here whether or not NeverCalled is called.
Right, and making it static you get the -Wunused-function. Great.
This warning is about the NeverCalled function being unused though, and not about Do being unassigned before it's called. Curious, is there any way to get a warning for this? This is UB, correct? And the assignment is now known not to happen?
typedef int (*Function)();
static Function Do;
void main() { Do(); }