public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x
@ 2007-10-28 15:19 a dot chavasse at gmail dot com
2007-10-28 15:22 ` [Bug c++/33930] " a dot chavasse at gmail dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: a dot chavasse at gmail dot com @ 2007-10-28 15:19 UTC (permalink / raw)
To: gcc-bugs
g++43 -v:
Using built-in specs.Target: x86_64-unknown-linux-gnuConfigured with:
../gcc/configure --program-suffix=43 --disable-multilib
--enable-languages=c,c++Thread model: posixgcc version 4.3.0 20071028
(experimental) (GCC)
(it was built from svn trunk, revision 129693)
Not sure whether it really counts as a regression since it happens only in
c++0x experimental mode, but it does prevent code that normally compiles to
fail to do so when enabling c++0x mode, like the following snippet:
==========================
#include <stack>
void foo()
{
std::stack< const int* > somestack;
int* someptr = 0;
somestack.push( someptr );
}
==========================
It fails to build with --std=cxx0x with the following error:
rvalref-overload-stdstack.cpp: In function 'void foo()':
rvalref-overload-stdstack.cpp:7: error: call of overloaded 'push(int*&)' is
ambiguous
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_stack.h:188:
note: candidates are: void std::stack<_Tp, _Sequence>::push(const typename
_Sequence::value_type&) [with
_Tp = const int*, _Sequence = std::deque<const int*, std::allocator<const int*>
>]
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_stack.h:193:
note: void std::stack<_Tp, _Sequence>::push(typename
_Sequence::value_type&&) [with _Tp =
const int*, _Sequence = std::deque<const int*, std::allocator<const int*> >]
Here is a c++0x only test case not involving any headers that triggers the same
error with similar overloads:
==========================
typedef const int* type;
void foo( const type& ggg ) {}
void foo( type&& ggg ) {}
void bar( int* someptr )
{
foo( someptr );
}
==========================
--
Summary: [4.3 regression] ambiguous overload in
std::stack::push() when using --std=cxx0x
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: a dot chavasse at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33930] [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
@ 2007-10-28 15:22 ` a dot chavasse at gmail dot com
2007-10-28 15:39 ` [Bug c++/33930] [c++0x] " pcarlini at suse dot de
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: a dot chavasse at gmail dot com @ 2007-10-28 15:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from a dot chavasse at gmail dot com 2007-10-28 15:22 -------
(by --std=cxx0x I of course meant --std=c++0x)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
2007-10-28 15:22 ` [Bug c++/33930] " a dot chavasse at gmail dot com
@ 2007-10-28 15:39 ` pcarlini at suse dot de
2007-10-30 19:31 ` pcarlini at suse dot de
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-28 15:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pcarlini at suse dot de 2007-10-28 15:39 -------
Certainly can't be a regression. And certainly both overloads are present in
the most recent specifications (n2369). Doug, any chance you can comment on
this? I tend to consider this code invalid...
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |doug dot gregor at gmail dot
| |com, pcarlini at suse dot de
Summary|[4.3 regression] ambiguous |[c++0x] ambiguous overload
|overload in |in std::stack::push() when
|std::stack::push() when |using --std=cxx0x
|using --std=cxx0x |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
2007-10-28 15:22 ` [Bug c++/33930] " a dot chavasse at gmail dot com
2007-10-28 15:39 ` [Bug c++/33930] [c++0x] " pcarlini at suse dot de
@ 2007-10-30 19:31 ` pcarlini at suse dot de
2007-10-30 23:28 ` [Bug libstdc++/33930] " pcarlini at suse dot de
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-30 19:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pcarlini at suse dot de 2007-10-30 19:31 -------
If something (I doubt so, could only be a defect in n2369), this is a C++
issue, because the implementation in the library is totally trivial, identical
to the specifications.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|libstdc++ |c++
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (2 preceding siblings ...)
2007-10-30 19:31 ` pcarlini at suse dot de
@ 2007-10-30 23:28 ` pcarlini at suse dot de
2007-10-30 23:52 ` a dot chavasse at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-30 23:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pcarlini at suse dot de 2007-10-30 23:28 -------
Actually, I don't know. Definitely the library is conforming to n2369, but
maybe something is wrong in the specifications of the two push. I'm going to
investigate that, let's tentatively consider this as a library issue, because
seems unlikely that the G++ implementation of rvalue-reference overloading
rules is wrong.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|UNCONFIRMED |ASSIGNED
Component|c++ |libstdc++
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-10-30 23:28:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (3 preceding siblings ...)
2007-10-30 23:28 ` [Bug libstdc++/33930] " pcarlini at suse dot de
@ 2007-10-30 23:52 ` a dot chavasse at gmail dot com
2007-10-30 23:56 ` pcarlini at suse dot de
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: a dot chavasse at gmail dot com @ 2007-10-30 23:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from a dot chavasse at gmail dot com 2007-10-30 23:51 -------
Well, I did notice that the library was conforming to n2369, but I have really
no idea otherwise about this - except that it did break the compilation of some
really straightforward and innocent looking code of mine that was pushing const
pointers to objects on a stack so it did feel like something was wrong.
Perhaps an explicit cast to a const pointer is supposed to be necessary to
remove the ambiguity, but it feels counter-intuitive since it's my
understanding that the usage of rvalue references (and move semantics) instead
of lvalue references is meant to be a transparent optimization in most cases.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (4 preceding siblings ...)
2007-10-30 23:52 ` a dot chavasse at gmail dot com
@ 2007-10-30 23:56 ` pcarlini at suse dot de
2007-10-31 0:07 ` pcarlini at suse dot de
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-30 23:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2007-10-30 23:56 -------
You are right. I'm investigating the issue with the help of knowledgeable
people in this area, we should be able to resolve it rather quickly. A possible
"solution", which would essentially render the issue moot, is replacing the two
overloads with a single "emplace" overload, as per n2369 in the sequence
containers. We'll see...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (5 preceding siblings ...)
2007-10-30 23:56 ` pcarlini at suse dot de
@ 2007-10-31 0:07 ` pcarlini at suse dot de
2007-10-31 22:30 ` pcarlini at suse dot de
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-31 0:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pcarlini at suse dot de 2007-10-31 00:07 -------
For concreteness would be something like the below (you can try it out, but
consider that the underlying sequence container "emplace" push_back are not
implemented yet, therefore expect only backward compatibility with C++03):
Index: stl_stack.h
===================================================================
--- stl_stack.h (revision 129768)
+++ stl_stack.h (working copy)
@@ -184,14 +184,16 @@
* to it. The time complexity of the operation depends on the
* underlying sequence.
*/
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
void
push(const value_type& __x)
{ c.push_back(__x); }
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
- void
- push(value_type&& __x)
- { c.push_back(std::move(__x)); }
+#else
+ template<typename... _Args>
+ void
+ push(_Args&&... __args)
+ { c.push_back(std::forward<_Args>(__args)...); }
#endif
/**
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (6 preceding siblings ...)
2007-10-31 0:07 ` pcarlini at suse dot de
@ 2007-10-31 22:30 ` pcarlini at suse dot de
2007-11-01 1:24 ` [Bug libstdc++/33930] C++0x overloading problem with const lvalref and rvalref pcarlini at suse dot de
2007-11-05 18:45 ` [Bug c++/33930] " dgregor at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-10-31 22:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pcarlini at suse dot de 2007-10-31 22:30 -------
Update: on the LWG reflector Howard Hinnant replied that likely this is a bug
in the G++ implementation of rvalue references (I could not believe that!): the
conversion from int* to const int* leads to a temporary which then should bind
safely to the rvalue reference overload. Orthogonally, people apparently like
the idea of changing the container adaptors per Comment #7, therefore short
term our library can avoid the issue.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/33930] C++0x overloading problem with const lvalref and rvalref
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (7 preceding siblings ...)
2007-10-31 22:30 ` pcarlini at suse dot de
@ 2007-11-01 1:24 ` pcarlini at suse dot de
2007-11-05 18:45 ` [Bug c++/33930] " dgregor at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-11-01 1:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pcarlini at suse dot de 2007-11-01 01:24 -------
Ok, so I'm committing momentarily the single push changes to the library (per
my brand new DR 756) and at the same time fixing the Summary and recategorizing
to C++.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|pcarlini at suse dot de |unassigned at gcc dot gnu
| |dot org
Status|ASSIGNED |NEW
Summary|[c++0x] ambiguous overload |C++0x overloading problem
|in std::stack::push() when |with const lvalref and
|using --std=cxx0x |rvalref
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33930] C++0x overloading problem with const lvalref and rvalref
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
` (8 preceding siblings ...)
2007-11-01 1:24 ` [Bug libstdc++/33930] C++0x overloading problem with const lvalref and rvalref pcarlini at suse dot de
@ 2007-11-05 18:45 ` dgregor at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: dgregor at gcc dot gnu dot org @ 2007-11-05 18:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from dgregor at gcc dot gnu dot org 2007-11-05 18:45 -------
Fixed as part of PR33235
--
dgregor at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-11-05 18:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-28 15:19 [Bug c++/33930] New: [4.3 regression] ambiguous overload in std::stack::push() when using --std=cxx0x a dot chavasse at gmail dot com
2007-10-28 15:22 ` [Bug c++/33930] " a dot chavasse at gmail dot com
2007-10-28 15:39 ` [Bug c++/33930] [c++0x] " pcarlini at suse dot de
2007-10-30 19:31 ` pcarlini at suse dot de
2007-10-30 23:28 ` [Bug libstdc++/33930] " pcarlini at suse dot de
2007-10-30 23:52 ` a dot chavasse at gmail dot com
2007-10-30 23:56 ` pcarlini at suse dot de
2007-10-31 0:07 ` pcarlini at suse dot de
2007-10-31 22:30 ` pcarlini at suse dot de
2007-11-01 1:24 ` [Bug libstdc++/33930] C++0x overloading problem with const lvalref and rvalref pcarlini at suse dot de
2007-11-05 18:45 ` [Bug c++/33930] " dgregor 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).