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

            Bug ID: 23253
           Summary: Clang should not allow call constructor directly.
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

For the following code, clang++ could compile with -std=c++11, and give the
following output which is incorrect.


#include <iostream>
struct B
{
};

struct C
{
  C (){ std::cout << "C" << '\n'; }
  C (B *) { std::cout << "C (B *)" << '\n';}
};

B *y = nullptr;
int main()
{
  C::C (y);
}

output:

$ clang++  sfo.cpp -std=c++11
$ ./a.out
C

While g++ give an meaningful error message. 

$ g++  sfo.cpp -std=c++11
sfo.cpp: In function ‘int main()’:
sfo.cpp:34:10: error: cannot call constructor ‘C::C’ directly [-fpermissive]
   C::C (y);
          ^
sfo.cpp:34:10: note: for a function-style cast, remove the redundant ‘::C’




This bug  was from Stackoverflow.com question (
http://stackoverflow.com/q/29681449/566459 ).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to