Bug 1482990
Summary: | glibc-2.26-2.fc27 breaks assert on C++ objects: no match for 'operator==' | |||
---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Petr Pisar <ppisar> | |
Component: | ccgo | Assignee: | Petr Pisar <ppisar> | |
Status: | CLOSED NEXTRELEASE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | |
Severity: | unspecified | Docs Contact: | ||
Priority: | unspecified | |||
Version: | 27 | CC: | arjun.is, avi.kivity, codonell, dj, fweimer, jwakely, law, mfabian, pfrankli, ppisar, siddhesh | |
Target Milestone: | --- | |||
Target Release: | --- | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | ccgo-0.3.6.5-7.fc27 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1483005 (view as bug list) | Environment: | ||
Last Closed: | 2017-08-18 15:17:41 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: |
Description
Petr Pisar
2017-08-18 14:19:42 UTC
The C++ standard incorporates the C standard, which requires a comparison against 0: “ The assert macro puts diagnostic tests into programs; it expands to a void expression. When it is executed, if expression (which shall have a scalar type) is false (that is, compares equal to 0), the assert macro writes information about the particular call that failed […] ” This is arguably a defect in the C++ standard because it also talks about “contextually converted to bool”, but it is how things stand today: you need a valid operator== for comparison with int to use the assert macro. You can probably use this: assert(!!a); Thanks for the explanation. That makes sense. I also found assert(NULL!=a) not working on Glib::RefPtr objects. The assert(!!a) is better. We are still going to fix this in glibc, so I'm going to clone this bug. (In reply to Petr Pisar from comment #2) > I also found assert(NULL!=a) not working on Glib::RefPtr objects. The > assert(!!a) is better. Or assert(static_cast<bool>(a)) A library issue has been opened requesting clarification in the C++ standard: https://cplusplus.github.io/LWG/issue3011 My suggestion is that C++ adds explicit wording to repeat the C standard's requirement that the condition should have scalar type. So assert((bool)a) and assert(!!a) would be OK, but assert(a) would not. glibc-2.25-9.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-781951efb3 |