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

--- Comment #8 from Fernando Pelliccioni <fpelliccioni at gmail dot com> 
2012-05-07 13:24:02 UTC ---
Sorry, the comments were wrong.
Here the corrected code with proper comments.

Tested with GCC 4.7.1 and GCC 4.6.3


// g++ -std=c++0x gcc_error_simple.cpp
// g++ -DWITH_USING_DECLARATION -std=c++0x gcc_error_simple.cpp

#include <type_traits>

template <typename T>
struct Base
{
    template <typename T2>
    typename std::enable_if<std::is_same<T, T2>::value, T>::type
    get()
    {
        return T2();
    }
};

template <typename T>
struct Derived : Base<int>
{
    typedef Base<int> base;

#ifdef WITH_USING_DECLARATION
    using base::get;
#endif

    template <typename T2>
    typename std::enable_if<std::is_same<T, T2>::value, T>::type
    get()
    {
        return T2();
    }
};

int main( /* int argc, char* argv[] */ )
{
    Derived<double> d;

    auto xxx = d.get<double>();
    auto yyy = d.get<int>();    // #ifndef WITH_USING_DECLARATION ->
Compile-time error    -> GCC is behaving Correctly!!! Base<int>::get<int>() is
hidden!
                                // #ifdef  WITH_USING_DECLARATION -> No
Compile-time error -> GCC is behaving incorrectly. Base<int>::get<int>() must
be hidden.

    return 0;
}

Reply via email to