[LLVMbugs] [Bug 19896] New: Warn if overload resolution picks f(bool) over f(Foo*) when calling f with a const Foo*
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 30 04:35:40 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19896
Bug ID: 19896
Summary: Warn if overload resolution picks f(bool) over f(Foo*)
when calling f with a const Foo*
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: nicolasweber at gmx.de
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
This:
#include <iostream>
using namespace std;
class Foo {};
class Thingy {
public:
// Thingy can contain a bool, or a Foo.
//static Thingy* newThingy(bool b) {
// cout << "Creating bool Thingy" << endl;
// return NULL;
//}
static Thingy* newThingy(Foo* f) {
cout << "Creating Foo Thingy" << endl;
return NULL;
}
};
class Factory {
public:
static const Foo* gimmeFoo() { return new Foo(); }
};
int main() {
Thingy::newThingy(true);
Thingy::newThingy(Factory::gimmeFoo());
}
produces
Creating bool Thingy
Creating bool Thingy
newThingy(Foo*) can't be called because gimmeFoo() returns a const Foo*.
Because of that, const Foo* doesn't make it into the overload set and
overload-related warnings don't fire. But this is still surprising behavior, so
we should warn on this.
--
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/20140530/e1ceeb05/attachment.html>
More information about the llvm-bugs
mailing list