https://bugs.llvm.org/show_bug.cgi?id=38601

            Bug ID: 38601
           Summary: static cast a derived class to base class with defined
                    type case operators
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: luyi0...@gmail.com
                CC: llvm-bugs@lists.llvm.org

#include <iostream>
#include <tuple>

using Base = std::tuple<int,int>;

struct Derived : Base {

    template <class ...Ts>
    Derived(int x, Ts&&... ts): Base(std::forward<Ts>(ts)...), x(x) {
    }

    operator int () const {
        return x;
    }

    int x;
};

int main() {


    Derived d(1, 2, 3);

    Base b = static_cast<Base>(d);

    // he output is 0 1 in clang++, but the expected output is 2 3
    std::cout << std::get<0>(b) << " " << std::get<1>(b) << std::endl;

    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to