public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!=.
@ 2010-08-23 13:00 seysayux at gmail dot com
2010-08-23 13:17 ` [Bug c++/45383] [4.5/4.6 Regression] " redi at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: seysayux at gmail dot com @ 2010-08-23 13:00 UTC (permalink / raw)
To: gcc-bugs
Consider this code:
--------------------
#include <iostream>
struct null {
null() {}
template<class T>
operator T*() const {
return 0;
}
template<class C, class T>
operator T C::*() const {
return 0;
}
private:
null(const null&);
null& operator=(const null&);
void operator&() const;
};
static struct null null;
int main() {
int* ptr = null;
std::cout << (ptr == null) << ", " << (ptr != null);
return 0;
}
--------------------------------
This compiles and gives the expected output ("true, false") on the following
platforms:
http://codepad.org (GCC 4.1, Linux)
Ubuntu 9.10, GCC 4.3
Ubuntu 10.04, GCC 4.4
Mac OS X 10.6, GCC 4.2
Mac OS X 10.6, GCC 4.4
Cygwin, GCC 4.3
Cygwin, GCC 4.4
Unknown Linux variant, Clang 2.8 (trunk 111679) (the "clang" bot on
irc.freenode.net)
However, I get following error on these platforms
-------------
error: no match for 'operator==' in 'ptr == null'
-------------
Cygwin, GCC 4.5
Ubuntu 10.04, GCC 4.5
Unknown Linux variant, GCC 4.6.0 20100507 (the "geordi" bot on
irc.freenode.net)
The people in the irc.freenode.net/##c++ channel confirm that this is indeed
valid C++ code and therefore a bug in GCC.
I do not have ready access to some of these systems (anymore), so I can not say
with certainity what their host, target, or build triplets are.
--
Summary: [g++ >= 4.5 ] Implicit conversion to pointer does no
longer automatically generate operator== and operator!=.
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: seysayux at gmail dot com
GCC build triplet: (many, read below)
GCC host triplet: (many, read below)
GCC target triplet: (many, read below)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/45383] [4.5/4.6 Regression] Implicit conversion to pointer does no longer automatically generate operator== and operator!=.
2010-08-23 13:00 [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!= seysayux at gmail dot com
@ 2010-08-23 13:17 ` redi at gcc dot gnu dot org
2010-08-23 16:35 ` hjl dot tools at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-08-23 13:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from redi at gcc dot gnu dot org 2010-08-23 13:17 -------
The summary seems backwards: the conversion shouldn't generate operator==,
instead using operator== should trigger the conversion, but fails to when the
conversion operator is a template.
Strangely, adding a non-template conversion operator causes template argument
deduction to succeed, even though the non-template operator isn't used
e.g.
#include <iostream>
struct null {
null() {}
template<class T>
operator T*() const {
return 0;
}
template<class C, class T>
operator T C::*() const {
return 0;
}
private:
operator double*() const; // ???
null(const null&);
null& operator=(const null&);
void operator&() const;
};
static struct null null;
int main() {
int* ptr = null;
std::cout << (ptr == null) << ", " << (ptr != null);
return 0;
}
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|(many, read below) |
GCC host triplet|(many, read below) |
GCC target triplet|(many, read below) |
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2010-08-23 13:17:12
date| |
Summary|[g++ >= 4.5 ] Implicit |[4.5/4.6 Regression]
|conversion to pointer does |Implicit conversion to
|no longer automatically |pointer does no longer
|generate operator== and |automatically generate
|operator!=. |operator== and operator!=.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/45383] [4.5/4.6 Regression] Implicit conversion to pointer does no longer automatically generate operator== and operator!=.
2010-08-23 13:00 [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!= seysayux at gmail dot com
2010-08-23 13:17 ` [Bug c++/45383] [4.5/4.6 Regression] " redi at gcc dot gnu dot org
@ 2010-08-23 16:35 ` hjl dot tools at gmail dot com
2010-08-23 20:07 ` rguenth at gcc dot gnu dot org
2010-08-30 16:01 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-08-23 16:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from hjl dot tools at gmail dot com 2010-08-23 16:35 -------
It is caused by revision 155415:
http://gcc.gnu.org/ml/gcc-cvs/2009-12/msg00559.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dseketel at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/45383] [4.5/4.6 Regression] Implicit conversion to pointer does no longer automatically generate operator== and operator!=.
2010-08-23 13:00 [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!= seysayux at gmail dot com
2010-08-23 13:17 ` [Bug c++/45383] [4.5/4.6 Regression] " redi at gcc dot gnu dot org
2010-08-23 16:35 ` hjl dot tools at gmail dot com
@ 2010-08-23 20:07 ` rguenth at gcc dot gnu dot org
2010-08-30 16:01 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-23 20:07 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.5.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/45383] [4.5/4.6 Regression] Implicit conversion to pointer does no longer automatically generate operator== and operator!=.
2010-08-23 13:00 [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!= seysayux at gmail dot com
` (2 preceding siblings ...)
2010-08-23 20:07 ` rguenth at gcc dot gnu dot org
@ 2010-08-30 16:01 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-30 16:01 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-30 16:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-23 13:00 [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!= seysayux at gmail dot com
2010-08-23 13:17 ` [Bug c++/45383] [4.5/4.6 Regression] " redi at gcc dot gnu dot org
2010-08-23 16:35 ` hjl dot tools at gmail dot com
2010-08-23 20:07 ` rguenth at gcc dot gnu dot org
2010-08-30 16:01 ` rguenth at gcc dot gnu dot 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).