public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106993] New: GCC accepts invalid program involving templated conversion function
@ 2022-09-21 7:43 jlame646 at gmail dot com
2022-09-21 10:02 ` [Bug c++/106993] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: jlame646 at gmail dot com @ 2022-09-21 7:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106993
Bug ID: 106993
Summary: GCC accepts invalid program involving templated
conversion function
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following invalid(afaik) program is accepted by gcc and msvc. Demo link:
https://godbolt.org/z/E5crEqqfx
```
#include <string>
#include <string_view>
struct object{
operator std::string(){return "";}
};
struct foo{
foo operator[](std::string_view s){
return foo{};
}
template <typename T>
operator T(){
return object{};
}
};
int main(){
foo f;
std::string s = f["a"];
}
```
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-21 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 7:43 [Bug c++/106993] New: GCC accepts invalid program involving templated conversion function jlame646 at gmail dot com
2022-09-21 10:02 ` [Bug c++/106993] " redi at gcc dot gnu.org
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).