public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55580] New: internal compiler error: Segmentation fault - with variadic template parameter
@ 2012-12-03 21:13 arturswiderski82 at gmail dot com
  2012-12-03 22:42 ` [Bug c++/55580] " vlukas at gmx dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: arturswiderski82 at gmail dot com @ 2012-12-03 21:13 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55580
           Summary: internal compiler error: Segmentation fault - with
                    variadic template parameter
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arturswiderski82@gmail.com


Created attachment 28865
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28865
main.cpp to  reproduce  bug

Code( I belive  valid one ) listed  below  crashes compiler 
I compile it  with g++ -c  -std=c++11 main.cpp 



template < int const _speed >
struct ConstValue
{
    static int const  Value = _speed;
};

template<  typename ... _Rest >
struct Features
{
    typedef ConstValue< 0 > Average;
};


template< typename ... _Rest >
template< int const _speed >
struct Features<  ConstValue< _speed >,  _Rest  ... >
{
    typedef ConstValue< 2 > Average;
};


int  main ()
 {

    Features< ConstValue< 2 >, ConstValue< 2 > >::Average Oki;

     return 0;

 }


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

* [Bug c++/55580] internal compiler error: Segmentation fault - with variadic template parameter
  2012-12-03 21:13 [Bug c++/55580] New: internal compiler error: Segmentation fault - with variadic template parameter arturswiderski82 at gmail dot com
@ 2012-12-03 22:42 ` vlukas at gmx dot de
  2012-12-03 23:11 ` arturswiderski82 at gmail dot com
  2012-12-04  0:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: vlukas at gmx dot de @ 2012-12-03 22:42 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from vlukas at gmx dot de 2012-12-03 22:42:06 UTC ---
I believe the following reduced snippet reproduces the original crash:
-------------------------------------------------------------------

template<int> struct V { };

template<typename...> struct F { };

template<typename... Ps>
template<int I>
struct F<V<I>, Ps...>
{ };

F<V<0>> x;
--------------------------------------------------------------------

With gcc version 4.8.0 20121122 (experimental) (GCC) I get the following:
--------------------------------------------------------------------
55580.cc:10:9: internal compiler error: tree check: expected class
'expression', have 'constant' (integer_cst) in tree_operand_check, at
tree.h:4113
 F<V<0>> x;
         ^
0xc8eb59 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc_svn/gcc/tree.c:9006
0x4e32ed expr_check
        ../../gcc_svn/gcc/tree.h:3849
0x4e32ed tree_operand_check
        ../../gcc_svn/gcc/tree.h:4113
0x5af3f5 tree_operand_check
        ../../gcc_svn/gcc/tree.h:3870
0x5af3f5 unify_pack_expansion
        ../../gcc_svn/gcc/cp/pt.c:16058
0x5b385f unify
        ../../gcc_svn/gcc/cp/pt.c:16737
0x5b19cf unify
        ../../gcc_svn/gcc/cp/pt.c:16579
0x5b22ac unify
        ../../gcc_svn/gcc/cp/pt.c:16729
0x5b49fe get_class_bindings
        ../../gcc_svn/gcc/cp/pt.c:17439
0x5b566c most_specialized_class
        ../../gcc_svn/gcc/cp/pt.c:17688
0x5c2840 instantiate_class_template_1
        ../../gcc_svn/gcc/cp/pt.c:8514
0x5c2840 instantiate_class_template(tree_node*)
        ../../gcc_svn/gcc/cp/pt.c:9019
0x64d83b complete_type(tree_node*)
        ../../gcc_svn/gcc/cp/typeck.c:134
0x54c385 start_decl_1(tree_node*, bool)
        ../../gcc_svn/gcc/cp/decl.c:4665
0x56bd42 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc_svn/gcc/cp/decl.c:4628
0x63a538 cp_parser_init_declarator
        ../../gcc_svn/gcc/cp/parser.c:15882
0x63aede cp_parser_simple_declaration
        ../../gcc_svn/gcc/cp/parser.c:10546
0x63cd87 cp_parser_block_declaration
        ../../gcc_svn/gcc/cp/parser.c:10427
0x645c0b cp_parser_declaration
        ../../gcc_svn/gcc/cp/parser.c:10324
0x64483d cp_parser_declaration_seq_opt
        ../../gcc_svn/gcc/cp/parser.c:10210
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
------------------------------------------------------------------------------

The backtrace I get from the original testcase is slightly different, but the
toplevel is the same ("internal compiler error: tree check: expected class
'expression', have 'constant' (integer_cst) in tree_operand_check, at
tree.h:4113").


I do not know whether the introduction of a second template parameter list  for
the partial specialization is valid C++. It can be made to work by changing it
to:
------------------------------------------------
template< typename ... _Rest, int const _speed >
//template< int const _speed >
struct Features<  ConstValue< _speed >,  _Rest  ... >
----------------------------------------------

I hope that helps.


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

* [Bug c++/55580] internal compiler error: Segmentation fault - with variadic template parameter
  2012-12-03 21:13 [Bug c++/55580] New: internal compiler error: Segmentation fault - with variadic template parameter arturswiderski82 at gmail dot com
  2012-12-03 22:42 ` [Bug c++/55580] " vlukas at gmx dot de
@ 2012-12-03 23:11 ` arturswiderski82 at gmail dot com
  2012-12-04  0:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: arturswiderski82 at gmail dot com @ 2012-12-03 23:11 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from arturswiderski82 at gmail dot com <arturswiderski82 at gmail dot com> 2012-12-03 23:10:49 UTC ---
Yes it solved my problem thanks


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

* [Bug c++/55580] internal compiler error: Segmentation fault - with variadic template parameter
  2012-12-03 21:13 [Bug c++/55580] New: internal compiler error: Segmentation fault - with variadic template parameter arturswiderski82 at gmail dot com
  2012-12-03 22:42 ` [Bug c++/55580] " vlukas at gmx dot de
  2012-12-03 23:11 ` arturswiderski82 at gmail dot com
@ 2012-12-04  0:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-04  0:12 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-04
                 CC|arturswiderski82 at gmail   |
                   |dot com                     |
     Ever Confirmed|0                           |1
           Severity|major                       |normal


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

end of thread, other threads:[~2012-12-04  0:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-03 21:13 [Bug c++/55580] New: internal compiler error: Segmentation fault - with variadic template parameter arturswiderski82 at gmail dot com
2012-12-03 22:42 ` [Bug c++/55580] " vlukas at gmx dot de
2012-12-03 23:11 ` arturswiderski82 at gmail dot com
2012-12-04  0:12 ` 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).