public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63149] New: can't initialize std::vector<T> from auto-deduced type 'const std::initializer_list<T> &'
@ 2014-09-03 1:04 richard-gccbugzilla at metafoo dot co.uk
2014-09-03 1:11 ` [Bug c++/63149] wrong auto deduction from braced-init-list ppluzhnikov at google dot com
2014-12-13 18:49 ` ville.voutilainen at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: richard-gccbugzilla at metafoo dot co.uk @ 2014-09-03 1:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63149
Bug ID: 63149
Summary: can't initialize std::vector<T> from auto-deduced type
'const std::initializer_list<T> &'
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: richard-gccbugzilla at metafoo dot co.uk
Reduced testcase:
namespace std {
template<typename T> struct initializer_list {
const T *p; unsigned long n;
initializer_list(const T *p, unsigned long n);
};
}
struct vector { vector(std::initializer_list<int>); };
void f(vector);
const auto &r = {1, 2, 3};
int main() { f(r); }
GCC rejects-valid here, saying:
<stdin>:10:15: error: could not convert ‘r’ from ‘const
std::initializer_list<const int>’ to ‘vector’
Replacing
const auto &r = {1, 2, 3};
with any of
const std::initializer_list<int> &r = {1, 2, 3};
auto &&r = {1, 2, 3};
auto r = {1, 2, 3};
... makes the problem disappear, so it seems that the 'const' from the
reference is somehow getting muddled into the
>From gcc-bugs-return-461068-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Sep 03 01:07:30 2014
Return-Path: <gcc-bugs-return-461068-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6374 invoked by alias); 3 Sep 2014 01:07:29 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6347 invoked by uid 48); 3 Sep 2014 01:07:24 -0000
From: "richard-gccbugzilla at metafoo dot co.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63149] wrong auto deduction from braced-init-list
Date: Wed, 03 Sep 2014 01:07:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: richard-gccbugzilla at metafoo dot co.uk
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: short_desc
Message-ID: <bug-63149-4-Vg6u0Kz70a@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63149-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63149-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-09/txt/msg00902.txt.bz2
Content-length: 898
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc149
Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|can't initialize |wrong auto deduction from
|std::vector<T> from |braced-init-list
|auto-deduced type 'const |
|std::initializer_list<T> &' |
--- Comment #1 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
... deduced type. [Oops, hit 'enter' early.]
Even simpler testcase:
#include <initializer_list>
const auto r = { 1, 2, 3 };
using X = decltype(r);
using X = const std::initializer_list<int>;
fails because decltype(r) is deduced as 'const std::initializer_list<const
int>' rather than 'const std::initializer_list<int>'.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/63149] wrong auto deduction from braced-init-list
2014-09-03 1:04 [Bug c++/63149] New: can't initialize std::vector<T> from auto-deduced type 'const std::initializer_list<T> &' richard-gccbugzilla at metafoo dot co.uk
@ 2014-09-03 1:11 ` ppluzhnikov at google dot com
2014-12-13 18:49 ` ville.voutilainen at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: ppluzhnikov at google dot com @ 2014-09-03 1:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63149
Paul Pluzhnikov <ppluzhnikov at google dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppluzhnikov at google dot com
--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Google ref: b/17312516
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/63149] wrong auto deduction from braced-init-list
2014-09-03 1:04 [Bug c++/63149] New: can't initialize std::vector<T> from auto-deduced type 'const std::initializer_list<T> &' richard-gccbugzilla at metafoo dot co.uk
2014-09-03 1:11 ` [Bug c++/63149] wrong auto deduction from braced-init-list ppluzhnikov at google dot com
@ 2014-12-13 18:49 ` ville.voutilainen at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-13 18:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63149
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-12-13
CC| |ville.voutilainen at gmail dot com
Ever confirmed|0 |1
Known to fail| |4.8.2, 4.9.1, 5.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-13 18:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03 1:04 [Bug c++/63149] New: can't initialize std::vector<T> from auto-deduced type 'const std::initializer_list<T> &' richard-gccbugzilla at metafoo dot co.uk
2014-09-03 1:11 ` [Bug c++/63149] wrong auto deduction from braced-init-list ppluzhnikov at google dot com
2014-12-13 18:49 ` ville.voutilainen at gmail 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).