public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58449] New: templated cast operator and failed template deduction on copy-construction via assign operator
@ 2013-09-17 18:39 forestshade at hotmail dot de
2013-09-17 23:03 ` [Bug c++/58449] templated cast operator and failed template deduction on copy initialization redi at gcc dot gnu.org
2020-11-03 6:27 ` gcc-im5revto at tobiasrenger dot name
0 siblings, 2 replies; 3+ messages in thread
From: forestshade at hotmail dot de @ 2013-09-17 18:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58449
Bug ID: 58449
Summary: templated cast operator and failed template deduction
on copy-construction via assign operator
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: forestshade at hotmail dot de
The following code produces a compiler error:
-------------------------
#include <iostream>
using namespace std;
struct S {
};
class A {
public:
A(void* ptr) : ptr(ptr) {}
void* ptr;
template<typename T>
operator const T&() const {
return *static_cast<T*>(ptr);
}
};
int main() {
S test;
A a(&test);
S s = a;
return 0;
}
-------------------------
while this one doesn't:
-------------------------
#include <iostream>
using namespace std;
struct S {
};
class A {
public:
A(void* ptr) : ptr(ptr) {}
void* ptr;
operator const S&() const {
return *static_cast<S*>(ptr);
}
};
int main() {
S test;
A a(&test);
S s = a;
return 0;
}
-------------------------
I'm not exactly sure if the standard allows the line "S s = a;" in this case
but the code above should either both succeed or both fail.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-03 6:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-17 18:39 [Bug c++/58449] New: templated cast operator and failed template deduction on copy-construction via assign operator forestshade at hotmail dot de
2013-09-17 23:03 ` [Bug c++/58449] templated cast operator and failed template deduction on copy initialization redi at gcc dot gnu.org
2020-11-03 6:27 ` gcc-im5revto at tobiasrenger dot name
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).