[QGIS-Developer] cppcheck false positive

Matthias Kuhn matthias at opengis.ch
Tue Sep 29 08:54:36 PDT 2020


On Tue, Sep 29, 2020 at 1:07 PM Alessandro Pasotti <apasotti at gmail.com>
wrote:

> On Tue, Sep 29, 2020 at 12:57 PM Denis Rouzaud <denis.rouzaud at gmail.com>
> wrote:
> >
> > Side question, is there a technical reason to prefer this syntax over
> the = one?
> >
> > The = is more readable to me, but that's a matter of experience I guess.
> > More generally, it would be nice to decide for one syntax and have a
> coherence over the source code.
> >
> > Cheers,
> > Denis
> >
>
> Hi Denis,
>
> I agree about the need for coherence, we currently have a mix of = ()
> and {} initialization.
>
> I'm not such an expert to tell you which is the best, but I've found
> this explanations quite convincing:
>
>
> https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es23-prefer-the--initializer-syntax
>
> https://stackoverflow.com/questions/18222926/why-is-list-initialization-using-curly-braces-better-than-the-alternatives
>
> That is the reason why I switched to {} as my preferred method.
>
> Cheers
>
> > Le mar. 29 sept. 2020 à 11:55, Alessandro Pasotti <apasotti at gmail.com>
> a écrit :
> >>
> >> Looks like cppcheck is not smart enough...
> >>
> >> const double factor { std::pow( 10, - mPrecisionSpinBox->value() ) };
> >>
> >>
> https://github.com/qgis/QGIS/pull/39079/checks?check_run_id=1181360827#step:4:1693
> >>
> >> --
> >> Alessandro Pasotti
> >> QCooperative:  www.qcooperative.net
> >> ItOpen:   www.itopen.it
> >> _______________________________________________
> >> QGIS-Developer mailing list
> >> QGIS-Developer at lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> There are certainly some advantages of {} (guessing since it wouldn't have
been added to the standard otherwise).

However... We have been bitten by incompatibilities (compiler and/or c++
version) more than once. And the more I read about it, the more I am
convinced that proper and conscious usage is not a simple task. See also
the controversial discussion in the stackoverflow link Alessandro posted.
So far it has failed to convince me as an adequate mitigation for the
problems it tries to solve.

Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200929/61e20e50/attachment-0001.html>


More information about the QGIS-Developer mailing list