Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-21525

Compiler warning about catching polymorphic exceptions by value

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw, cpputils, daf_base
    • Labels:
      None

      Description

      Starting with devtoolset-8, gcc-8 warns about catching polymorphic exceptions by value. As far as I understand, this is a bad coding practice in general.

       

      The occurrence I've checked regarding ip_diffim build in afw/math/Statistics.h:115 is harmless, and I'll change it as part of DM-21422.

       

      A list of places to check are grepped and attached.

       

      http://ptgmedia.pearsoncmg.com/images/0321113586/items/sutter_item73.pdf

       

      In file included from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Background.h:34,
       from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math.h:33,
       from examples/maskedKernel.cc:2:
       /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h: In constructor 'lsst::afw::math::StatisticsControl::StatisticsControl(double, int, lsst::afw::image::MaskPixel, bool, lsst::afw::math::StatisticsControl::WeightsBoolean)':
       /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h:115:41: warning: catching polymorphic type 'class lsst::pex::exceptions::InvalidParameterError' by value [-Wcatch-value=]
       } catch (lsst::pex::exceptions::InvalidParameterError) \{
       ^~~~~~~~~~~~~~~~~~~~~
      

        Attachments

          Issue Links

            Activity

            No builds found.
            gkovacs Gabor Kovacs [X] (Inactive) created issue -
            gkovacs Gabor Kovacs [X] (Inactive) made changes -
            Field Original Value New Value
            Attachment stack_20191001_catch_files.txt [ 40478 ]
            Attachment stack_20191001_catch.txt [ 40479 ]
            gkovacs Gabor Kovacs [X] (Inactive) made changes -
            Attachment stack_20191001_catch.txt [ 40479 ]
            gkovacs Gabor Kovacs [X] (Inactive) made changes -
            Attachment sutter_item73.pdf [ 40481 ]
            gkovacs Gabor Kovacs [X] (Inactive) made changes -
            Link This issue relates to DM-21422 [ DM-21422 ]
            gkovacs Gabor Kovacs [X] (Inactive) made changes -
            Component/s pex_policy [ 13620 ]
            Component/s utils [ 10723 ]
            swinbank John Swinbank made changes -
            Labels PairCoding
            swinbank John Swinbank made changes -
            Description Starting with devtoolset-8, gcc-8 warns about catching polymorphic exceptions by value. As far as I understand, this is a bad coding practice in general.

             

            The occurrence I've checked regarding ip_diffim build in afw/math/Statistics.h:115 is harmless, and I'll change it as part of DM-21422.

             

            A list of places to check are grepped and attached.

             

            [http://ptgmedia.pearsoncmg.com/images/0321113586/items/sutter_item73.pdf]

             
            {quote}In file included from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Background.h:34,
             from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math.h:33,
             from examples/maskedKernel.cc:2:
             /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h: In constructor 'lsst::afw::math::StatisticsControl::StatisticsControl(double, int, lsst::afw::image::MaskPixel, bool, lsst::afw::math::StatisticsControl::WeightsBoolean)':
             /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h:115:41: warning: catching polymorphic type 'class lsst::pex::exceptions::InvalidParameterError' by value [-Wcatch-value=]
             } catch (lsst::pex::exceptions::InvalidParameterError) \{
             ^~~~~~~~~~~~~~~~~~~~~
            {quote}
            Starting with devtoolset-8, gcc-8 warns about catching polymorphic exceptions by value. As far as I understand, this is a bad coding practice in general.

             

            The occurrence I've checked regarding ip_diffim build in afw/math/Statistics.h:115 is harmless, and I'll change it as part of DM-21422.

             

            A list of places to check are grepped and attached.

             

            [http://ptgmedia.pearsoncmg.com/images/0321113586/items/sutter_item73.pdf]

             
            {code}
            In file included from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Background.h:34,
             from /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math.h:33,
             from examples/maskedKernel.cc:2:
             /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h: In constructor 'lsst::afw::math::StatisticsControl::StatisticsControl(double, int, lsst::afw::image::MaskPixel, bool, lsst::afw::math::StatisticsControl::WeightsBoolean)':
             /software/lsstsw/stack_20191001/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0-17-gd2166b6e4/include/lsst/afw/math/Statistics.h:115:41: warning: catching polymorphic type 'class lsst::pex::exceptions::InvalidParameterError' by value [-Wcatch-value=]
             } catch (lsst::pex::exceptions::InvalidParameterError) \{
             ^~~~~~~~~~~~~~~~~~~~~
            {code}
            swinbank John Swinbank made changes -
            Story Points 4
            swinbank John Swinbank made changes -
            Epic Link DM-21441 [ 423048 ]
            swinbank John Swinbank made changes -
            Team Alert Production [ 10300 ]
            swinbank John Swinbank made changes -
            Story Points 4 2
            swinbank John Swinbank made changes -
            Epic Link DM-21441 [ 423048 ] DM-22484 [ 427311 ]
            swinbank John Swinbank made changes -
            Epic Link DM-22484 [ 427311 ] DM-24339 [ 433026 ]
            swinbank John Swinbank made changes -
            Epic Link DM-24339 [ 433026 ] DM-25139 [ 435257 ]
            swinbank John Swinbank made changes -
            Epic Link DM-25139 [ 435257 ] DM-26810 [ 439762 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-26810 [ 439762 ] DM-27906 [ 442554 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-27906 [ 442554 ] DM-29214 [ 459218 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-29214 [ 459218 ] DM-30436 [ 504824 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-30436 [ 504824 ] DM-30501 [ 510159 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-30501 [ 510159 ] DM-30502 [ 510160 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-30502 [ 510160 ] DM-30506 [ 510172 ]
            horvat Nikolina Horvat made changes -
            Epic Link DM-30506 [ 510172 ] DM-34931 [ 1598492 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-34931 [ 1598492 ] DM-36006 [ 1997396 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-36006 [ 1997396 ] DM-36522 [ 2254239 ]
            sullivan Ian Sullivan made changes -
            Epic Link DM-36522 [ 2254239 ] DM-36523 [ 2254240 ]
            tjenness Tim Jenness made changes -
            Component/s cpputils [ 20722 ]
            Component/s pex_policy [ 13620 ]
            Component/s utils [ 10723 ]
            Hide
            tjenness Tim Jenness added a comment -

            Jim Bosch I have no idea if this is still an afw compiler problem.

            Show
            tjenness Tim Jenness added a comment - Jim Bosch I have no idea if this is still an afw compiler problem.
            Hide
            jbosch Jim Bosch added a comment -

            This is not a compiler problem; the compiler is right to complain, though it's not usually a critical problem (I'd put it at about the same level as using a mutable container as a default argument in Python). I haven't seen instances of this myself, but if Gabor grepped for them it's probably worth keeping that list and fixing them.

            Matthias Wittgen, is this something your clang-tidy sweeps might have already taken care of for us?

            Show
            jbosch Jim Bosch added a comment - This is not a compiler problem; the compiler is right to complain, though it's not usually a critical problem (I'd put it at about the same level as using a mutable container as a default argument in Python). I haven't seen instances of this myself, but if Gabor grepped for them it's probably worth keeping that list and fixing them. Matthias Wittgen , is this something your clang-tidy sweeps might have already taken care of for us?
            Hide
            wittgen Matthias Wittgen added a comment -

            Yes. We can do one more clang-tidy run on the C++ code base and close this ticket.

            Show
            wittgen Matthias Wittgen added a comment - Yes. We can do one more clang-tidy run on the C++ code base and close this ticket.
            wittgen Matthias Wittgen made changes -
            Assignee Matthias Wittgen [ wittgen ]
            wittgen Matthias Wittgen made changes -
            Status To Do [ 10001 ] In Progress [ 3 ]
            Hide
            wittgen Matthias Wittgen added a comment - - edited

            Compiling the stack with -Werror=catch-value passed. Closing this ticket as done.

            Show
            wittgen Matthias Wittgen added a comment - - edited Compiling the stack with -Werror=catch-value passed. Closing this ticket as done.
            wittgen Matthias Wittgen made changes -
            Status In Progress [ 3 ] In Review [ 10004 ]
            wittgen Matthias Wittgen made changes -
            Status In Review [ 10004 ] Reviewed [ 10101 ]
            wittgen Matthias Wittgen made changes -
            Resolution Done [ 10000 ]
            Status Reviewed [ 10101 ] Done [ 10002 ]
            wittgen Matthias Wittgen made changes -
            Story Points 2 0.5
            Team Alert Production [ 10300 ] Architecture [ 10304 ]
            Watchers Gabor Kovacs [X], Jim Bosch, Matthias Wittgen, Tim Jenness [ Gabor Kovacs [X], Jim Bosch, Matthias Wittgen, Tim Jenness ] Jim Bosch, Matthias Wittgen, Tim Jenness [ Jim Bosch, Matthias Wittgen, Tim Jenness ]
            Labels PairCoding

              People

              Assignee:
              wittgen Matthias Wittgen
              Reporter:
              gkovacs Gabor Kovacs [X] (Inactive)
              Watchers:
              Jim Bosch, Matthias Wittgen, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.