public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation
@ 2012-05-27 13:58 o.mangold at googlemail dot com
  2012-05-27 15:33 ` [Bug c++/53498] " daniel.kruegler at googlemail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: o.mangold at googlemail dot com @ 2012-05-27 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53498
           Summary: Compiler crashes during C++11 template magic
                    compilation
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: o.mangold@googlemail.com


I was trying to create some template magic to create a check for the existence
of a function with variable number of arguments in C++11. Honestly, I don't
know, if my code should compile through, as the problem happened when I was
trying to figure out how to make it work. I got a compiler crash (which I guess
shouldn't happen in any case). I cooked it down to the example below:

> g++ -std=c++11 Crash.cxx

g++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
kiwi/SafePrintf$g++ -std=c++11 Crash.cxx 
g++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
---

--- Crash.cxx ---
template<typename... ARGS>
class A
{
public:
  template<typename U>
  auto a(const U& u,const ARGS&... args,int) -> decltype(u.print(args...))

  {
  }
  template<typename U>
  int a(const U& u,const ARGS&... args,...)

  {
  }

};

template<typename... ARGS>
class B
{
public:
  template<typename U> static void
  b(const U& u,const ARGS&... args,
    decltype(A<ARGS...>::a(u,args...,0)) dummy)
  {
  }
};

int main() {

  B<int> dummy;

  return 0;
}


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
@ 2012-05-27 15:33 ` daniel.kruegler at googlemail dot com
  2012-05-27 16:01 ` o.mangold at googlemail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-27 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-27 14:32:40 UTC ---
While the test code is somewhat broken, I found some suspicious compiler
behaviour when rewriting this into the following form, compiled with 
-std=c++11 -Wall using gcc 4.8.0 20120520 (experimental):

//------------
template<typename... Args>
struct A
{
  template<typename U>
  static
  auto a(const U& u, const Args&... args, int) -> decltype(u.print(args...))
  {
    return u.print(args...);
  }
  template<typename U>
  static
  int a(const U& u, const Args&... args, ...)
  {
    return 0;
  }
};

template<typename... Args>
struct B
{
  template<typename U>
  static
  void b(const U& u, const Args&... args, decltype(A<Args...>::a(u, args...,
0)) dummy)
  {
  }
};

int main() {
  A<int>::a(0, 0, 0); // OK
  B<int>::b(0, 0, 0); // ?
}
//------------ 

On my mingw build there is no diagnostics and no binary output produced except
that the compiler does not return successfully due to the last line
instantiating B<int>. In my experience that gives a seg fault on other systems,
so I recommend to run it through another system.


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
  2012-05-27 15:33 ` [Bug c++/53498] " daniel.kruegler at googlemail dot com
@ 2012-05-27 16:01 ` o.mangold at googlemail dot com
  2012-05-27 16:45 ` daniel.kruegler at googlemail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: o.mangold at googlemail dot com @ 2012-05-27 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from o.mangold at googlemail dot com 2012-05-27 15:33:16 UTC ---
(In reply to comment #1)
> While the test code is somewhat broken, 

Yes, I'm not surprised, this template stuff is a complete nightmare to me. As
you mention it, you don't accidently know, how a correct version would look? I
want to test, if the class U has a method print compatible with the given ARGS.


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
  2012-05-27 15:33 ` [Bug c++/53498] " daniel.kruegler at googlemail dot com
  2012-05-27 16:01 ` o.mangold at googlemail dot com
@ 2012-05-27 16:45 ` daniel.kruegler at googlemail dot com
  2012-06-26  3:43 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-27 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-27 16:09:04 UTC ---
(In reply to comment #2)
> As you mention it, you don't accidently know, how a correct version would look? 

This request would be off-topic here, but I responded off-list to you. 

> I want to test, if the class U has a method print compatible with the given
> ARGS.

Your example does not perform any kind of "test", so I'm not sure that I
understand your question correctly [But keep in mind that any responses to that
issue here should concentrate on the bug report, not on details of C++
programming techniques].


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
                   ` (2 preceding siblings ...)
  2012-05-27 16:45 ` daniel.kruegler at googlemail dot com
@ 2012-06-26  3:43 ` jason at gcc dot gnu.org
  2012-06-26  3:46 ` jason at gcc dot gnu.org
  2012-06-26  3:47 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2012-06-26  3:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-26 03:42:44 UTC ---
Author: jason
Date: Tue Jun 26 03:42:34 2012
New Revision: 188973

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188973
Log:
    PR c++/53498
    PR c++/53305
    * pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN
    if cp_unevaluated_operand is set.
    (tsubst_copy) [PARM_DECL]: Don't copy before tsubsting.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype38.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic132.C


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
                   ` (3 preceding siblings ...)
  2012-06-26  3:43 ` jason at gcc dot gnu.org
@ 2012-06-26  3:46 ` jason at gcc dot gnu.org
  2012-06-26  3:47 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2012-06-26  3:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |squidbidness at gmail dot
                   |                            |com

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-26 03:42:44 UTC ---
Author: jason
Date: Tue Jun 26 03:42:34 2012
New Revision: 188973

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188973
Log:
    PR c++/53498
    PR c++/53305
    * pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN
    if cp_unevaluated_operand is set.
    (tsubst_copy) [PARM_DECL]: Don't copy before tsubsting.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype38.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic132.C

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-26 03:42:56 UTC ---
Author: jason
Date: Tue Jun 26 03:42:48 2012
New Revision: 188974

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188974
Log:
    PR c++/53498
    PR c++/53305
    * pt.c (tsubst_pack_expansion): Copy before dummy tsubst.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/decltype38.C
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/variadic132.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/pt.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-26 03:44:42 UTC ---
*** Bug 53545 has been marked as a duplicate of this bug. ***


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

* [Bug c++/53498] Compiler crashes during C++11 template magic compilation
  2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
                   ` (4 preceding siblings ...)
  2012-06-26  3:46 ` jason at gcc dot gnu.org
@ 2012-06-26  3:47 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2012-06-26  3:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.2

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-26 03:46:34 UTC ---
Fixed for 4.7.2.


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

end of thread, other threads:[~2012-06-26  3:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-27 13:58 [Bug c++/53498] New: Compiler crashes during C++11 template magic compilation o.mangold at googlemail dot com
2012-05-27 15:33 ` [Bug c++/53498] " daniel.kruegler at googlemail dot com
2012-05-27 16:01 ` o.mangold at googlemail dot com
2012-05-27 16:45 ` daniel.kruegler at googlemail dot com
2012-06-26  3:43 ` jason at gcc dot gnu.org
2012-06-26  3:46 ` jason at gcc dot gnu.org
2012-06-26  3:47 ` 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).