Skip to content

Conversation

@apolukhin
Copy link
Member

This patch fixes GCC and CLANG compilation when RTTI is off. Tested on clang-3.0, clang-3.4. gcc-4.6

This patch is essential for Boost.TypeIndex library which must be tested with RTTI off and RTTI on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will create test cases with duplicate name, as BOOST_CURRENT_FUNCTION applies to generate_test_case_4_type::operator().

I understand that without RTTI, we are unable to retrieve the name of the current type. Any chance to have at least the index of the current type?

@apolukhin
Copy link
Member Author

Actually it will output the name of the TestType:

#include <iostream>
#include <boost/current_function.hpp>

template <class TestType>
struct generate_test_case_4_type
{
    void operator()() const {
        std::cout << BOOST_CURRENT_FUNCTION;
    }
};

struct print_me{};

int main()
{
    generate_test_case_4_type<print_me> p;
    p();
}

That piece of code will output: void generate_test_case_4_type<print_me>::operator()() const
print_me structure is in there, so there'll be no duplicate names.

Belcourt added a commit that referenced this pull request May 7, 2014
Make Boost.Test work with RTTI off

Looks reasonable, will watch develop tests to ensure no adverse issues arise.
@Belcourt Belcourt merged commit 1192491 into boostorg:develop May 7, 2014
@apolukhin apolukhin deleted the develop branch May 7, 2014 05:27
ecatmur added a commit to ecatmur/test that referenced this pull request Feb 15, 2021
Detected by asan with gcc10:

==863==ERROR: AddressSanitizer: invalid-pointer-pair: 0x7ffe21c831b0 0x00000c26f470
    #0 0x2688702 in boost::unit_test::framework::state::priority_order::operator()(boost::unit_test::test_observer*, boost::unit_test::test_observer*) const libs/test/include/boost/test/impl/framework.ipp:865
    boostorg#1 0x2688702 in std::_Rb_tree<boost::unit_test::test_observer*, boost::unit_test::test_observer*, std::_Identity<boost::unit_test::test_observer*>, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::_M_get_insert_unique_pos(boost::unit_test::test_observer* const&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_tree.h:2101
    boostorg#2 0x268aafb in std::pair<std::_Rb_tree_iterator<boost::unit_test::test_observer*>, bool> std::_Rb_tree<boost::unit_test::test_observer*, boost::unit_test::test_observer*, std::_Identity<boost::unit_test::test_observer*>, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::_M_insert_unique<boost::unit_test::test_observer*>(boost::unit_test::test_observer*&&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_tree.h:2154
    boostorg#3 0x2614ac4 in std::set<boost::unit_test::test_observer*, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::insert(boost::unit_test::test_observer*&&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_set.h:521
    boostorg#4 0x2614ac4 in boost::unit_test::framework::register_observer(boost::unit_test::test_observer&) libs/test/include/boost/test/impl/framework.ipp:1380
    boostorg#5 0x2642b56 in boost::unit_test::framework::register_observer_helper::register_obs() libs/test/include/boost/test/impl/framework.ipp:1627
    boostorg#6 0x2642b56 in boost::unit_test::framework::run(unsigned long, bool) libs/test/include/boost/test/impl/framework.ipp:1731
    boostorg#7 0x27f6c77 in boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) libs/test/include/boost/test/impl/unit_test_main.ipp:250
    boostorg#8 0x27f9495 in main libs/test/include/boost/test/impl/unit_test_main.ipp:306
    boostorg#9 0x7f8d8b3c1554 in __libc_start_main ../csu/libc-start.c:266
    boostorg#10 0x568e0d  (test+0x568e0d)
ecatmur added a commit to ecatmur/test that referenced this pull request Feb 15, 2021
Detected by asan with gcc10:

==863==ERROR: AddressSanitizer: invalid-pointer-pair: 0x7ffe21c831b0 0x00000c26f470
    #0 0x2688702 in boost::unit_test::framework::state::priority_order::operator()(boost::unit_test::test_observer*, boost::unit_test::test_observer*) const libs/test/include/boost/test/impl/framework.ipp:865
    boostorg#1 0x2688702 in std::_Rb_tree<boost::unit_test::test_observer*, boost::unit_test::test_observer*, std::_Identity<boost::unit_test::test_observer*>, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::_M_get_insert_unique_pos(boost::unit_test::test_observer* const&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_tree.h:2101
    boostorg#2 0x268aafb in std::pair<std::_Rb_tree_iterator<boost::unit_test::test_observer*>, bool> std::_Rb_tree<boost::unit_test::test_observer*, boost::unit_test::test_observer*, std::_Identity<boost::unit_test::test_observer*>, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::_M_insert_unique<boost::unit_test::test_observer*>(boost::unit_test::test_observer*&&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_tree.h:2154
    boostorg#3 0x2614ac4 in std::set<boost::unit_test::test_observer*, boost::unit_test::framework::state::priority_order, std::allocator<boost::unit_test::test_observer*> >::insert(boost::unit_test::test_observer*&&) /opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_set.h:521
    boostorg#4 0x2614ac4 in boost::unit_test::framework::register_observer(boost::unit_test::test_observer&) libs/test/include/boost/test/impl/framework.ipp:1380
    boostorg#5 0x2642b56 in boost::unit_test::framework::register_observer_helper::register_obs() libs/test/include/boost/test/impl/framework.ipp:1627
    boostorg#6 0x2642b56 in boost::unit_test::framework::run(unsigned long, bool) libs/test/include/boost/test/impl/framework.ipp:1731
    boostorg#7 0x27f6c77 in boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) libs/test/include/boost/test/impl/unit_test_main.ipp:250
    boostorg#8 0x27f9495 in main libs/test/include/boost/test/impl/unit_test_main.ipp:306
    boostorg#9 0x7f8d8b3c1554 in __libc_start_main ../csu/libc-start.c:266
    boostorg#10 0x568e0d  (test+0x568e0d)

Clarify formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants