Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2137 closed Bugs (invalid)

BOOST_CONCEPT_REQUIRES fails on g++

Reported by: john.femiani@… Owned by:
Milestone: Boost 1.36.0 Component: None
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

The mingw-g++ compiler seems to fail to prevent BOOST_CONCEPT_REQUIRES from working properly.

It is failing to prevent a function from being instantiated, and instead it is issuing an error.

This is being discussed on the newslist here.

This is a sample g++ error:

 g++ test.cpp 
test.cpp: In instantiation of 'DummyConcept<foo<int> >':
c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/has_constraints.hpp:40:   instantiated from 'const bool boost::concept::not_satisfied<DummyConcept<foo<int> > >::value'
c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/has_constraints.hpp:43:   instantiated from 'boost::concept::not_satisfied<DummyConcept<foo<int> > >'
c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/mpl/if.hpp:67:   instantiated from 'boost::mpl::if_<boost::concept::not_satisfied<DummyConcept<foo<int> > >, boost::concept::constraint<DummyConcept<foo<int> > >, boost::concept::requirement<DummyConcept<foo<int> > > >'
c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/general.hpp:19:   instantiated from 'boost::concept::requirement_<void (*)(DummyConcept<foo<int> >)>'
c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/requires.hpp:30:   instantiated from 'boost::_requires_<void (*)(DummyConcept<foo<int> >)>'
test.cpp:35:   instantiated from here
test.cpp:14: error: no type named 'something' in 'struct foo<int>'

Attachments (1)

test.cpp (603 bytes ) - added by john.femiani@… 14 years ago.
Sourcecode that produces the error.

Download all attachments as: .zip

Change History (5)

by john.femiani@…, 14 years ago

Attachment: test.cpp added

Sourcecode that produces the error.

comment:1 by Dave Abrahams, 14 years ago

The library is doing what it's supposed to do on GCC. In general, it isn't possible to check for concept conformance without causing an error, so BOOST_CONCEPT_REQUIRES is supposed to cause an error if conformance fails. It doesn't try to do SFINAE, because, in general, SFINAE is not possible.

I probably should have put this in the docs, but I didn't quite realize it until now: an overloaded function that uses BOOST_CONCEPT_REQUIRES should only require the least-refined concept in the overload set. Otherwise the concept check will cause compilation to fail if a more-refined model is passed. If you want to check for a more refined model, you need to use BOOST_CONCEPT_ASSERT((...)) in the function body.

comment:2 by Dave Abrahams, 14 years ago

Resolution: invalid
Status: newclosed

comment:3 by john, 14 years ago

If it is not doing SFINAE then why even have BOOST_CONCEPT_REQUIRES? Is it just to move the conditions to approximately where they would belong in C++0x?

in reply to:  3 comment:4 by john, 14 years ago

Replying to john:

If it is not doing SFINAE then why even have BOOST_CONCEPT_REQUIRES? Is it just to move the conditions to approximately where they would belong in C++0x?

Don't bother to answer -- I know the answer.

Note: See TracTickets for help on using tickets.