Std::function parameters of overriden functions cannot be changed in a template

Hello there,

we have this false positive in SimGrid (that use the public instance of sonarcloud) where a function parameter should be changed from std::function into template:
https://sonarcloud.io/project/issues?id=simgrid_simgrid&issues=AWsDvTgQezZPqKif7D-B&open=AWsDvTgQezZPqKif7D-B

This is perfectly true that this code is naive enough to be converted, as the parameter is even ignored:

Context* ContextFactory::create_maestro(std::function<void()>&&, actor::ActorImpl*)
{
  xbt_die("Cannot create_maestro with this ContextFactory.\n"
    "Try using --cfg=contexts/factory:thread instead.\n");
}

But the thing is that create_maestro is an overridden function and that the non-trivial occurences of this fonction cannot be modified in the way hinted by sonar. See for example here (if previous link eventually breaks, search for create_maestro around here).

The false positive may come from the fact that the function reported as changeable is not marked override itself. It’s virtual, overriden by other functions elsewhere.

Thanks for this great tool,

Hello @mquinson,

This is a true false-positive. We will fix it in the next release. This ticket will help to track the issue.

Thanks for your valuable detailed reporting!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.