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

            Bug ID: 49375
           Summary: statically recognizable type-errors result in broken
                    binaries (?)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: heiko.le...@worldiety.de
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

The following program compiles to a binary where the float is handled before
the int member. VC++ recognizes the error of print() taking rvalue references.
gcc yields the same result clang.

I think such errors should be caught. see https://gcc.godbolt.org/z/G4ddao



struct Test {
   int m_x;
   float m_y;

   template<class Callable>
   void withMembers(Callable&& callable) {
     callable(m_x, m_y);
   }
};


extern void print(int&&i);
extern void print(float&&i);

int notmain()
{
    Test t{ .m_x=1, .m_y=2.0f};

    t.withMembers([](const auto&... args){
        (  print(args), ...);
    });
    return t.m_x;
}

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

Reply via email to