public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50075] New: ICE related to parameter deduction and initializer_list
@ 2011-08-13 13:46 z0sh at sogetthis dot com
  2011-08-13 14:09 ` [Bug c++/50075] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: z0sh at sogetthis dot com @ 2011-08-13 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50075
           Summary: ICE related to parameter deduction and
                    initializer_list
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: z0sh@sogetthis.com
              Host: x86
            Target: x86


[Please rephrase the title with something more appropriate, I don't know how to
pin this down.]

I was trying to deduce the size parameter of an std::array<T,N> from the size
of an initializer list. The following code is probably not correct, but in any
event, it causes GCC 4.6.1 with -std=c++0x to crash:



#include <functional>
#include <array>

template <typename T, unsigned int N>
std::array<T, N> make_array_helper(const std::initializer_list<T> & il)
{
  return std::array<T, N>(il);
}

template <typename T>
auto make_array(const std::initializer_list<T> & il) ->
decltype(make_array(il))
{
  return make_array_helper<T, il.size()>(il);
}

int main()
{
  auto z = make_array({{1,2}});
}


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

* [Bug c++/50075] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
@ 2011-08-13 14:09 ` redi at gcc dot gnu.org
  2011-08-13 14:28 ` z0sh at sogetthis dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-13 14:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-13 14:00:45 UTC ---
obviously it shouldn't crash, but what you're trying  won't work, because
initializer_list::size is not constexpr, so il.size() is not a constant
expression


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

* [Bug c++/50075] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
  2011-08-13 14:09 ` [Bug c++/50075] " redi at gcc dot gnu.org
@ 2011-08-13 14:28 ` z0sh at sogetthis dot com
  2011-08-13 15:56 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: z0sh at sogetthis dot com @ 2011-08-13 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Kerrek SB <z0sh at sogetthis dot com> 2011-08-13 14:09:20 UTC ---
Indeed, according to the FDIS size() is *not* constexpr, but I had initially
just checked the GCC implementation, in which it *is* declared as constexpr!
(This is in "c++/4.6.1/initializer_list".)


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

* [Bug c++/50075] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
  2011-08-13 14:09 ` [Bug c++/50075] " redi at gcc dot gnu.org
  2011-08-13 14:28 ` z0sh at sogetthis dot com
@ 2011-08-13 15:56 ` redi at gcc dot gnu.org
  2011-08-13 23:02 ` [Bug c++/50075] [C++0x] " jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-13 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-13 15:42:06 UTC ---
ah, sorry, I didn't check our impl - so then it should work, just isn't
portable


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

* [Bug c++/50075] [C++0x] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
                   ` (2 preceding siblings ...)
  2011-08-13 15:56 ` redi at gcc dot gnu.org
@ 2011-08-13 23:02 ` jason at gcc dot gnu.org
  2011-08-14  4:43 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-13 23:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-08-13
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.7.0
     Ever Confirmed|0                           |1

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-13 22:00:34 UTC ---
The problem is the recursion:

template <typename T>
auto make_array(const std::initializer_list<T> & il) ->
decltype(make_array(il))

You're declaring make_array to have the same return type as itself.  4.6
happily goes down the rabbit hole until it runs out of stack.  4.7 complains
and then crashes for another reason, which I will fix.


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

* [Bug c++/50075] [C++0x] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
                   ` (3 preceding siblings ...)
  2011-08-13 23:02 ` [Bug c++/50075] [C++0x] " jason at gcc dot gnu.org
@ 2011-08-14  4:43 ` jason at gcc dot gnu.org
  2011-08-14  8:12 ` jason at gcc dot gnu.org
  2011-08-15 13:58 ` z0sh at sogetthis dot com
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-14  4:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-14 04:41:49 UTC ---
Author: jason
Date: Sun Aug 14 04:41:43 2011
New Revision: 177743

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177743
Log:
    PR c++/50075
    * name-lookup.c (local_bindings_p): New.
    * name-lookup.h: Declare it.
    * lex.c (unqualified_name_lookup_error): Use it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype32.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lex.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/name-lookup.h
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/50075] [C++0x] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
                   ` (4 preceding siblings ...)
  2011-08-14  4:43 ` jason at gcc dot gnu.org
@ 2011-08-14  8:12 ` jason at gcc dot gnu.org
  2011-08-15 13:58 ` z0sh at sogetthis dot com
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-14  8:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-14 04:43:39 UTC ---
Fixed for 4.7.


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

* [Bug c++/50075] [C++0x] ICE related to parameter deduction and initializer_list
  2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
                   ` (5 preceding siblings ...)
  2011-08-14  8:12 ` jason at gcc dot gnu.org
@ 2011-08-15 13:58 ` z0sh at sogetthis dot com
  6 siblings, 0 replies; 8+ messages in thread
From: z0sh at sogetthis dot com @ 2011-08-15 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Kerrek SB <z0sh at sogetthis dot com> 2011-08-15 13:57:51 UTC ---
This is great, thank you!


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

end of thread, other threads:[~2011-08-15 13:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-13 13:46 [Bug c++/50075] New: ICE related to parameter deduction and initializer_list z0sh at sogetthis dot com
2011-08-13 14:09 ` [Bug c++/50075] " redi at gcc dot gnu.org
2011-08-13 14:28 ` z0sh at sogetthis dot com
2011-08-13 15:56 ` redi at gcc dot gnu.org
2011-08-13 23:02 ` [Bug c++/50075] [C++0x] " jason at gcc dot gnu.org
2011-08-14  4:43 ` jason at gcc dot gnu.org
2011-08-14  8:12 ` jason at gcc dot gnu.org
2011-08-15 13:58 ` z0sh at sogetthis 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).