[Bug libstdc++/53578] New: include/ext/concurrence.h relies on ill-formed narrowing conversions

richard-gccbugzilla at metafoo dot co.uk gcc-bugzilla@gcc.gnu.org
Mon Jun 4 23:53:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53578

             Bug #: 53578
           Summary: include/ext/concurrence.h relies on ill-formed
                    narrowing conversions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: richard-gccbugzilla@metafoo.co.uk


>From around line 271 of ext/concurrence.h:

// matches a gthr-win32.h recursive mutex
template<typename _Rm>
static typename __enable_if<sizeof(&_Rm::sema), void>::__type
_S_destroy(_Rm* __mx)

This SFINAE device doesn't work in Clang in C++11 mode, because the sizeof
expression evaluates to a value greater than one, and thus the implicit
conversion to bool for the first template parameter is a narrowing conversion.

I assume g++ will hit this too once it adds support for the narrowing check in
converted constant expressions.



More information about the Gcc-bugs mailing list