public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
@ 2013-04-11  7:03 zeratul976 at hotmail dot com
  2013-04-11  7:34 ` [Bug c++/56915] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-11  7:03 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56915
           Summary: [4.9 regression] ICE in
                    symtab_add_to_same_comdat_group, at symtab.c:383
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


For the following code:


template <typename T>
class A
{
    typename T::type b();
};

template <typename T, typename U>
void waldo(T, U);

template <typename T>
void bar()
{
    waldo([](A<T> a){ return a; },  
          []{});
}

int main()
{   
    bar<int>();
}


GCC 4.9 (r197687) gives the following output:


test.cpp: In instantiation of 'class A<int>':
test.cpp:13:20:   required from 'bar() [with T = int]::__lambda0'
test.cpp:13:12:   required from 'struct bar() [with T = int]::__lambda0'
test.cpp:14:15:   required from 'void bar() [with T = int]'
test.cpp:19:14:   required from here
test.cpp:4:22: error: 'int' is not a class, struct, or union type
     typename T::type b();
                      ^
test.cpp: In instantiation of 'struct bar() [with T = int]::__lambda1':
test.cpp:14:15:   required from 'void bar() [with T = int]'
test.cpp:19:14:   required from here
test.cpp:14:12: internal compiler error: in symtab_add_to_same_comdat_group, at
symtab.c:383
           []{});
            ^
0x7ae403 symtab_add_to_same_comdat_group(symtab_node_def*, symtab_node_def*)
        ../../src/gcc/symtab.c:383
0x687031 maybe_add_lambda_conv_op(tree_node*)
        ../../src/gcc/cp/semantics.c:9767
0x5a20e8 instantiate_class_template_1
        ../../src/gcc/cp/pt.c:9028
0x5a20e8 instantiate_class_template(tree_node*)
        ../../src/gcc/cp/pt.c:9081
0x62b02b complete_type(tree_node*)
        ../../src/gcc/cp/typeck.c:131
0x56325c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:14532
0x5640a3 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:13955
0x56bfaf tsubst_expr
        ../../src/gcc/cp/pt.c:13376
0x56c50f tsubst_expr
        ../../src/gcc/cp/pt.c:12855
0x56ba4b tsubst_expr
        ../../src/gcc/cp/pt.c:12841
0x56c824 tsubst_expr
        ../../src/gcc/cp/pt.c:13031
0x56a3fb instantiate_decl(tree_node*, int, bool)
        ../../src/gcc/cp/pt.c:18904
0x5a5946 instantiate_pending_templates(int)
        ../../src/gcc/cp/pt.c:19003
0x5e073d cp_write_global_declarations()
        ../../src/gcc/cp/decl2.c:4031


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
@ 2013-04-11  7:34 ` rguenth at gcc dot gnu.org
  2013-04-12  7:29 ` shixiong at kugelworks dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-11  7:34 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org
   Target Milestone|---                         |4.9.0


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
  2013-04-11  7:34 ` [Bug c++/56915] " rguenth at gcc dot gnu.org
@ 2013-04-12  7:29 ` shixiong at kugelworks dot com
  2013-04-12  7:40 ` zeratul976 at hotmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: shixiong at kugelworks dot com @ 2013-04-12  7:29 UTC (permalink / raw)
  To: gcc-bugs


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

Shixiong <shixiong at kugelworks dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shixiong at kugelworks dot
                   |                            |com

--- Comment #1 from Shixiong <shixiong at kugelworks dot com> 2013-04-12 07:29:38 UTC ---
I am not an expert of C++11, but I am trying to help you with this ICE. Before
I jump into the compiler to find the bugs, I guess you probably made several
mistakes in your given code.

1) when lambdas are used as parameters, I think, they should be written in
either function pointer (no state) or functional object (with state, dependent
on outside vars).

2) it declared "typename T::type b()", but instantiated the class with int, but
int do not  have a filed named type.

3)C++11 seems to only support monomorphic lambdas, if you want to use
polymorphic lambdas, you probably should use other libraries like Boost.

If changed into the following code, it works.

template <typename T>
class A
{
 T b(); // Note: still cannot use 'typename T::type b()'
};


template <typename T, typename U>
void waldo(T, U);

template <typename T>
void bar()
{
  A<T> (*func_pointer1) (A<T>) = [](A<T> a) { return a; };
  void (*func_pointer2) () = []() { };
    waldo(func_pointer2,
          func_pointer1);
//  waldo ([](A<T> a) { return a; }, []() { });
}

int main()
{
    bar<int>();
}

Anyway, it is just my personal opinion. If I made mistakes, pls. tell me.


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
  2013-04-11  7:34 ` [Bug c++/56915] " rguenth at gcc dot gnu.org
  2013-04-12  7:29 ` shixiong at kugelworks dot com
@ 2013-04-12  7:40 ` zeratul976 at hotmail dot com
  2013-04-23 23:09 ` shixiong at kugelworks dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-12  7:40 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Nathan Ridge <zeratul976 at hotmail dot com> 2013-04-12 07:40:46 UTC ---
(In reply to comment #1)
> I am not an expert of C++11, but I am trying to help you with this ICE. Before
> I jump into the compiler to find the bugs, I guess you probably made several
> mistakes in your given code.

I know the code is invalid. However, an ICE is always a compiler bug, even if
it's for invalid code. The compiler should give proper errors for invalid code.
(In this case it gives the ICE after giving the proper errors - that's still a
bug). Also, an ICE on invalid code can indicate a logic error in the compiler's
code that may also be causing (yet to be discovered) ICEs on valid code.


Also, just FYI:

> 3)C++11 seems to only support monomorphic lambdas, if you want to use
> polymorphic lambdas, you probably should use other libraries like Boost.

Using a lambda inside a template does not make it polymorphic. Each
instantiation of the template will have a different, monomorphic, lambda.


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
                   ` (2 preceding siblings ...)
  2013-04-12  7:40 ` zeratul976 at hotmail dot com
@ 2013-04-23 23:09 ` shixiong at kugelworks dot com
  2013-04-23 23:10 ` shixiong at kugelworks dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: shixiong at kugelworks dot com @ 2013-04-23 23:09 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Shixiong <shixiong at kugelworks dot com> 2013-04-23 23:09:17 UTC ---
Created attachment 29924
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29924
Patch for PR56915


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
                   ` (3 preceding siblings ...)
  2013-04-23 23:09 ` shixiong at kugelworks dot com
@ 2013-04-23 23:10 ` shixiong at kugelworks dot com
  2013-04-24  9:16 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: shixiong at kugelworks dot com @ 2013-04-23 23:10 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Shixiong <shixiong at kugelworks dot com> 2013-04-23 23:09:58 UTC ---
Please see the attached Patch for this ICE.


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
                   ` (4 preceding siblings ...)
  2013-04-23 23:10 ` shixiong at kugelworks dot com
@ 2013-04-24  9:16 ` paolo.carlini at oracle dot com
  2013-04-24  9:36 ` shixiong at kugelworks dot com
  2013-05-23  4:22 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-24  9:16 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-24 09:16:20 UTC ---
Normally patches go to gcc-patches.


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
                   ` (5 preceding siblings ...)
  2013-04-24  9:16 ` paolo.carlini at oracle dot com
@ 2013-04-24  9:36 ` shixiong at kugelworks dot com
  2013-05-23  4:22 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: shixiong at kugelworks dot com @ 2013-04-24  9:36 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Shixiong <shixiong at kugelworks dot com> 2013-04-24 09:36:13 UTC ---
(In reply to comment #5)
yes, I know that. I just want to let the bug submitter have a try.
> Normally patches go to gcc-patches.


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

* [Bug c++/56915] [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383
  2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
                   ` (6 preceding siblings ...)
  2013-04-24  9:36 ` shixiong at kugelworks dot com
@ 2013-05-23  4:22 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2013-05-23  4:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2013-05-23  4:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11  7:03 [Bug c++/56915] New: [4.9 regression] ICE in symtab_add_to_same_comdat_group, at symtab.c:383 zeratul976 at hotmail dot com
2013-04-11  7:34 ` [Bug c++/56915] " rguenth at gcc dot gnu.org
2013-04-12  7:29 ` shixiong at kugelworks dot com
2013-04-12  7:40 ` zeratul976 at hotmail dot com
2013-04-23 23:09 ` shixiong at kugelworks dot com
2013-04-23 23:10 ` shixiong at kugelworks dot com
2013-04-24  9:16 ` paolo.carlini at oracle dot com
2013-04-24  9:36 ` shixiong at kugelworks dot com
2013-05-23  4:22 ` jason at gcc dot gnu.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).