[LLVMbugs] [Bug 23253] New: Clang should not allow call constructor directly.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Apr 16 11:12:58 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: kunling at lingcc.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150416/86c86d4f/attachment.html>
More information about the llvm-bugs
mailing list