public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
@ 2007-11-08 1:54 sergey dot gcc at comrades dot id dot au
2007-11-08 1:58 ` [Bug c++/34023] " sergey dot gcc at comrades dot id dot au
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: sergey dot gcc at comrades dot id dot au @ 2007-11-08 1:54 UTC (permalink / raw)
To: gcc-bugs
// gcc version 3.4.5 (mingw-special)
class a
{
public:
template<class T>
operator T &() const
{
static int f;
return f; // line # 10
}
/*
// unsafe workaround:
operator a const &() const
{
return *this;
}
*/
};
int main()
{
// : In member function `a::operator T&() const [with T = const a]':
// :27: instantiated from here
// :10: error: invalid initialization of reference of type 'const a&'
from expression of type 'int'
a const &aa = a(); // line # 27
/*
// workaround:
a const temp;
a const &aa = temp;
*/
}
--
Summary: Wrong using of user-defined conversion operator for
converting rvalue to reference on constant.
Product: gcc
Version: 3.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sergey dot gcc at comrades dot id dot au
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
@ 2007-11-08 1:58 ` sergey dot gcc at comrades dot id dot au
2007-11-08 2:04 ` sergey dot gcc at comrades dot id dot au
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: sergey dot gcc at comrades dot id dot au @ 2007-11-08 1:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sergey dot gcc at comrades dot id dot au 2007-11-08 01:58 -------
I've checked other versions of compiler, such as 3.4.6 and 4.X.X. Can someone
check?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
2007-11-08 1:58 ` [Bug c++/34023] " sergey dot gcc at comrades dot id dot au
@ 2007-11-08 2:04 ` sergey dot gcc at comrades dot id dot au
2007-11-09 1:14 ` sergey dot gcc at comrades dot id dot au
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: sergey dot gcc at comrades dot id dot au @ 2007-11-08 2:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from sergey dot gcc at comrades dot id dot au 2007-11-08 02:03 -------
(In reply to comment #1)
> I've checked other versions of compiler, such as 3.4.6 and 4.X.X. Can someone
> check?
>
Sorry, I mean, I have *NOT*.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
2007-11-08 1:58 ` [Bug c++/34023] " sergey dot gcc at comrades dot id dot au
2007-11-08 2:04 ` sergey dot gcc at comrades dot id dot au
@ 2007-11-09 1:14 ` sergey dot gcc at comrades dot id dot au
2007-11-19 4:15 ` pinskia at gcc dot gnu dot org
2007-11-29 0:04 ` sergey dot gcc at comrades dot id dot au
4 siblings, 0 replies; 7+ messages in thread
From: sergey dot gcc at comrades dot id dot au @ 2007-11-09 1:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from sergey dot gcc at comrades dot id dot au 2007-11-09 01:14 -------
// Workaround:
class a
{
public:
template<class T>
operator T &() const
throw(typename ::boost::disable_if<
::boost::is_same<T, ref_t const> >::type *)
{
static int f;
return f;
}
};
int main()
{
a const &aa = a(); // line # 27
int &i = aa;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
` (2 preceding siblings ...)
2007-11-09 1:14 ` sergey dot gcc at comrades dot id dot au
@ 2007-11-19 4:15 ` pinskia at gcc dot gnu dot org
2007-11-29 0:04 ` sergey dot gcc at comrades dot id dot au
4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-19 4:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2007-11-19 04:15 -------
This works on the trunk.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
` (3 preceding siblings ...)
2007-11-19 4:15 ` pinskia at gcc dot gnu dot org
@ 2007-11-29 0:04 ` sergey dot gcc at comrades dot id dot au
4 siblings, 0 replies; 7+ messages in thread
From: sergey dot gcc at comrades dot id dot au @ 2007-11-29 0:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from sergey dot gcc at comrades dot id dot au 2007-11-29 00:04 -------
(In reply to comment #3)
> // Workaround:
> class a
> {
> public:
> template<class T>
> operator T &() const
> throw(typename ::boost::disable_if<
> ::boost::is_same<T, ref_t const> >::type *)
> {
> static int f;
> return f;
> }
> };
>
> int main()
> {
> a const &aa = a(); // line # 27
> int &i = aa;
> }
>
This workaround should not work, according to the standard
14.8.2.2
- All references in the function type of the function template to the
corresponding template parameters are replaced by the specified template
argument values. If a substitution in a template parameter or in the function
type of the function template results in an invalid type, type deduction fails.
[Note: The equivalent substitution in exception specifications is done only
when the function is instantiated, at which point a program is ill-formed if
the substitution results in an invalid type.] Type deduction may fail for the
following reasons:
However, it works on GCC. It is another bug in GCC.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/34023] Wrong using of user-defined conversion operator for converting rvalue to reference on constant.
[not found] <bug-34023-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-25 22:07 ` paolo.carlini at oracle dot com
0 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-25 22:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34023
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC|gcc-bugs at gcc dot gnu.org |
Resolution| |FIXED
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-25 21:59:20 UTC ---
Fixed long ago.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-09-25 22:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 1:54 [Bug c++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant sergey dot gcc at comrades dot id dot au
2007-11-08 1:58 ` [Bug c++/34023] " sergey dot gcc at comrades dot id dot au
2007-11-08 2:04 ` sergey dot gcc at comrades dot id dot au
2007-11-09 1:14 ` sergey dot gcc at comrades dot id dot au
2007-11-19 4:15 ` pinskia at gcc dot gnu dot org
2007-11-29 0:04 ` sergey dot gcc at comrades dot id dot au
[not found] <bug-34023-4@http.gcc.gnu.org/bugzilla/>
2011-09-25 22:07 ` paolo.carlini at oracle dot com
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).