Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DescriptionPrabhanjan Gururaj
2019-05-30 08:59:51 UTC
Description of problem:
g++ fails as below:
error: catching polymorphic type ‘class ResourceMonitor::RMException’ by value [-Werror=catch-value=]
} catch (ResourceMonitor::RMException rme) {
Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 8.0 Beta (Ootpa)
kernel-4.18.0-74.el8.x86_64
gcc-c++-8.2.1-3.5.el8.x86_64
gcc-8.2.1-3.5.el8.x86_64
Details:
g++ -Wall -Werror -DLINUX -fpic -I/usr/include/libnl3 -I/usr/include -Ih/linux -Ih -Iobjs/product -Ideadman_module -Icfs/cmvxd -DSACTO -DQS -DENABLE_ENHANCED_SECURITY -Wno-deprecated -c -o objs/product/DiskAgentMain.o resserv/agents/disk/DiskAgentMain.cpp
Putting child 0x55d32b299460 (objs/product/DiskAgentMain.o) PID 18102 on the chain.
Live child 0x55d32b299460 (objs/product/DiskAgentMain.o) PID 18102
resserv/agents/disk/DiskAgentMain.cpp: In function ‘int main(int, const char**, const char**)’:
resserv/agents/disk/DiskAgentMain.cpp:12:43: error: catching polymorphic type ‘class ResourceMonitor::RMException’ by value [-Werror=catch-value=]
} catch (ResourceMonitor::RMException rme) {
^~~
cc1plus: all warnings being treated as errors
Reaping losing child 0x55d32b299460 PID 18102
Expected results:
The same piece of code is getting built successfully on gcc 4.8. I am seeing this issue only after moving to gcc8.2 with rhel8.
Additional info:
I see a similar error being posted in https://bugzilla.redhat.com/show_bug.cgi?id=1542888, but for qpid/fedora.
You are compiling with -Wall -Werror, so you need to be prepared to deal with new warnings that through those command line options are turned into errors.
-Wcatch-value is a new warning, introduced in GCC 8, so no wonder you haven't seen such a warning with GCC 4.8.
Either don't use -Werror, use -Wno-catch-value, disable the warning for the particular spot with #pragma GCC diagnostic or change the code.
The warning is documented as:
'-Wcatch-value'
'-Wcatch-value=N (C++ and Objective-C++ only)'
Warn about catch handlers that do not catch via reference. With
'-Wcatch-value=1' (or '-Wcatch-value' for short) warn about
polymorphic class types that are caught by value. With
'-Wcatch-value=2' warn about all class types that are caught by
value. With '-Wcatch-value=3' warn about all types that are not
caught by reference. '-Wcatch-value' is enabled by '-Wall'.
See also https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#e15-catch-exceptions-from-a-hierarchy-by-reference for rationale for that warning.
Comment 2Prabhanjan Gururaj
2019-05-30 10:52:38 UTC
Description of problem: g++ fails as below: error: catching polymorphic type ‘class ResourceMonitor::RMException’ by value [-Werror=catch-value=] } catch (ResourceMonitor::RMException rme) { Version-Release number of selected component (if applicable): Red Hat Enterprise Linux 8.0 Beta (Ootpa) kernel-4.18.0-74.el8.x86_64 gcc-c++-8.2.1-3.5.el8.x86_64 gcc-8.2.1-3.5.el8.x86_64 Details: g++ -Wall -Werror -DLINUX -fpic -I/usr/include/libnl3 -I/usr/include -Ih/linux -Ih -Iobjs/product -Ideadman_module -Icfs/cmvxd -DSACTO -DQS -DENABLE_ENHANCED_SECURITY -Wno-deprecated -c -o objs/product/DiskAgentMain.o resserv/agents/disk/DiskAgentMain.cpp Putting child 0x55d32b299460 (objs/product/DiskAgentMain.o) PID 18102 on the chain. Live child 0x55d32b299460 (objs/product/DiskAgentMain.o) PID 18102 resserv/agents/disk/DiskAgentMain.cpp: In function ‘int main(int, const char**, const char**)’: resserv/agents/disk/DiskAgentMain.cpp:12:43: error: catching polymorphic type ‘class ResourceMonitor::RMException’ by value [-Werror=catch-value=] } catch (ResourceMonitor::RMException rme) { ^~~ cc1plus: all warnings being treated as errors Reaping losing child 0x55d32b299460 PID 18102 Expected results: The same piece of code is getting built successfully on gcc 4.8. I am seeing this issue only after moving to gcc8.2 with rhel8. Additional info: I see a similar error being posted in https://bugzilla.redhat.com/show_bug.cgi?id=1542888, but for qpid/fedora.