public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58753] New: Brace-initializing a vector with a direct-initialization NSDMI doesn't work in a template
@ 2013-10-16 18:39 ville.voutilainen at gmail dot com
  2013-10-16 21:40 ` [Bug c++/58753] " paolo.carlini at oracle dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: ville.voutilainen at gmail dot com @ 2013-10-16 18:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58753

            Bug ID: 58753
           Summary: Brace-initializing a vector with a
                    direct-initialization NSDMI doesn't work in a template
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

This snippet doesn't work:

#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

template <class zomg> 
class T {
        vector<int> v{2,6,4,1,7,1}; // #1, fails
    static int comp(int x, int y) 
    {return x < y;} 
public: 
    void sort_me() {sort(v.begin(), v.end(), comp);} 
    void print_me() {for (auto x : v) cout << x << endl;}
}; 


int main()
{
  T<int> t;
    t.sort_me();
    t.print_me();
}

It works if T is not a class template. It also works if the line
marked #1 is written as
        vector<int> v = {2,6,4,1,7,1};
both in a class template and in a normal class. Fails the same
way with 4.7.2, 4.8 and 4.9 trunk.

Full diagnostics:
plaatti.cpp: In constructor ‘constexpr T<int>::T()’:
plaatti.cpp:8:7: error: no matching function for call to
‘std::vector<int>::vector(<brace-enclosed initializer list>)’
 class T {
       ^
plaatti.cpp:8:7: note: candidates are:
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:386:9: note: template<class
_InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator,
_InputIterator, const allocator_type&)
         vector(_InputIterator __first, _InputIterator __last,
         ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:386:9: note:   template argument
deduction/substitution failed:
plaatti.cpp:8:7: note:   cannot convert ‘4’ (type ‘int’) to type ‘const
allocator_type& {aka const std::allocator<int>&}’
 class T {
       ^
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:358:7: note: std::vector<_Tp,
_Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp =
int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<int>]
       vector(initializer_list<value_type> __l,
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:358:7: note:   candidate expects
2 arguments, 6 provided
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:334:7: note: std::vector<_Tp,
_Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp =
int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<int>]
       vector(vector&& __rv, const allocator_type& __m)
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:334:7: note:   candidate expects
2 arguments, 6 provided
/usr/local/include/c++/4.9.0/bits/stl_vector.h:325:7: note: std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with
_Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp,
_Alloc>::allocator_type = std::allocator<int>]
       vector(const vector& __x, const allocator_type& __a)
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:325:7: note:   candidate expects
2 arguments, 6 provided
/usr/local/include/c++/4.9.0/bits/stl_vector.h:321:7: note: std::vector<_Tp,
_Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc =
std::allocator<int>]
       vector(vector&& __x) noexcept
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:321:7: note:   candidate expects
1 argument, 6 provided
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:304:7: note: std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc =
std::allocator<int>]
       vector(const vector& __x)
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:304:7: note:   candidate expects
1 argument, 6 provided
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:275:7: note: std::vector<_Tp,
_Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const
allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>;
std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp,
_Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<int>]
       vector(size_type __n, const value_type& __value,
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:275:7: note:   candidate expects
3 arguments, 6 provided
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:263:7: note: std::vector<_Tp,
_Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&)
[with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp,
_Alloc>::size_type = long unsigned int; std::vector<_Tp,
_Alloc>::allocator_type = std::allocator<int>]
       vector(size_type __n, const allocator_type& __a = allocator_type())
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:263:7: note:   candidate expects
2 arguments, 6 provided
In file included from /usr/local/include/c++/4.9.0/vector:64:0,
                 from plaatti.cpp:1:
/usr/local/include/c++/4.9.0/bits/stl_vector.h:250:7: note: std::vector<_Tp,
_Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc =
std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<int>]
       vector(const allocator_type& __a = allocator_type()) _GLIBCXX_NOEXCEPT
       ^
/usr/local/include/c++/4.9.0/bits/stl_vector.h:250:7: note:   candidate expects
1 argument, 6 provided
plaatti.cpp: In function ‘int main()’:
plaatti.cpp:20:10: note: synthesized method ‘constexpr T<int>::T()’ first
required here 
   T<int> t;
          ^
>From gcc-bugs-return-431969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 16 18:52:59 2013
Return-Path: <gcc-bugs-return-431969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27659 invoked by alias); 16 Oct 2013 18:52:59 -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 27638 invoked by uid 48); 16 Oct 2013 18:52:56 -0000
From: "juergen.reuter at desy dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58754] New: ICE/Regression in [4.7/4.8/4.9] with allocatable character arrays
Date: Wed, 16 Oct 2013 18:52:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: juergen.reuter at desy dot de
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-58754-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: 2013-10/txt/msg01113.txt.bz2
Content-length: 620

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX754

            Bug ID: 58754
           Summary: ICE/Regression in [4.7/4.8/4.9] with allocatable
                    character arrays
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juergen.reuter at desy dot de

This code causes an ICE in 4.7/4.8/4.9, but worked in 4.6
(not sure whether this has been reported already):
character, allocatable :: c(:)
allocate (c (1), source = " ")
end


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-11-19  9:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-16 18:39 [Bug c++/58753] New: Brace-initializing a vector with a direct-initialization NSDMI doesn't work in a template ville.voutilainen at gmail dot com
2013-10-16 21:40 ` [Bug c++/58753] " paolo.carlini at oracle dot com
2013-10-16 22:13 ` ville.voutilainen at gmail dot com
2013-10-16 22:23 ` paolo.carlini at oracle dot com
2013-10-16 22:26 ` ville.voutilainen at gmail dot com
2013-10-16 22:30 ` ville.voutilainen at gmail dot com
2013-10-21 22:06 ` ville.voutilainen at gmail dot com
2013-10-21 22:33 ` paolo.carlini at oracle dot com
2014-05-15  9:02 ` paolo.carlini at oracle dot com
2014-05-15 11:38 ` ville.voutilainen at gmail dot com
2014-05-15 12:19 ` paolo.carlini at oracle dot com
2014-05-15 12:31 ` ville.voutilainen at gmail dot com
2014-05-20 19:21 ` paolo at gcc dot gnu.org
2014-05-20 19:22 ` paolo.carlini at oracle dot com
2014-07-01 18:47 ` ppluzhnikov at gcc dot gnu.org
2014-07-02  7:52 ` christophe.lyon at st dot com
2014-07-02  8:07 ` christophe.lyon at st dot com
2014-11-19  9:19 ` 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).