public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
@ 2007-06-07 10:30 rsalmin2 at cc dot hut dot fi
2007-06-07 10:31 ` [Bug c++/32241] " rsalmin2 at cc dot hut dot fi
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: rsalmin2 at cc dot hut dot fi @ 2007-06-07 10:30 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2638 bytes --]
/*
$ cat /proc/version
Linux version 2.6.20-15-generic (root@yellow) (gcc version 4.1.2 (Ubuntu
4.1.2-0ubuntu4)) #2 SMP Sun Apr 15 06:17:24 UTC 2007
$ gcc --version
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ simplestack.cpp -o simplestack -g
simplestack.cpp: In member function void SimpleStack<T, N>::pop() [with T =
int, long unsigned int N = 4ul]:
simplestack.cpp:52: instantiated from here
simplestack.cpp:32: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
preprocessed source: http://cpp.sourceforge.net/?show=36942
*/
#include <stdexcept>
#include <memory>
template <typename T, std::size_t N>
class SimpleStack
{
public:
SimpleStack()
: ptr(reinterpret_cast<T*>(&buffer[0]))
{
}
void push(const T& element)
{
if(num >= N) throw std::out_of_range("stack full");
new (ptr + num) T(element);
++num;
}
bool empty() const
{
return num <= 0;
}
T& top()
{
return *(ptr + num - 1);
}
void pop()
{
top.~T(); // this is the line causing the error!
--num;
}
private:
SimpleStack(const SimpleStack&);
SimpleStack& operator=(const SimpleStack&);
char buffer[N * sizeof(T)];
T *ptr;
std::size_t num;
};
#include <iostream>
int main()
{
SimpleStack<int, 4> stack;
stack.push(3);
std::cout << stack.top() << std::endl;
stack.pop();
}
--
Summary: Compiler segmentation fault when trying to call x.~X();
(X &x = f();) in a template
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rsalmin2 at cc dot hut dot fi
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
@ 2007-06-07 10:31 ` rsalmin2 at cc dot hut dot fi
2007-06-08 0:03 ` fang at csl dot cornell dot edu
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rsalmin2 at cc dot hut dot fi @ 2007-06-07 10:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rsalmin2 at cc dot hut dot fi 2007-06-07 10:30 -------
Created an attachment (id=13663)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13663&action=view)
Source code and preprocessed source
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
2007-06-07 10:31 ` [Bug c++/32241] " rsalmin2 at cc dot hut dot fi
@ 2007-06-08 0:03 ` fang at csl dot cornell dot edu
2007-06-08 10:16 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fang at csl dot cornell dot edu @ 2007-06-08 0:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fang at csl dot cornell dot edu 2007-06-08 00:03 -------
reduced test case:
==============================
template <typename T>
class SimpleStack {
public:
T& top() { return *ptr; }
void pop() { top.~T(); }
T *ptr;
};
int main(int, char*[]) {
SimpleStack<int> stack;
stack.pop();
return 0;
}
==============================
also ICEs 4.0.1 (apple) and 4.2.0.
keyword: ice-on-invalid
known to fail: 4.0.1, 4.2.0
3.3 (apple) gives:
error: destructor name `~int' does not match type `<unknown type>' of
expression
error: insufficient contextual information to determine type
3.4.6 silently accepts code and compiles.
Note: author probably meant "top().~T()" :)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
2007-06-07 10:31 ` [Bug c++/32241] " rsalmin2 at cc dot hut dot fi
2007-06-08 0:03 ` fang at csl dot cornell dot edu
@ 2007-06-08 10:16 ` rguenth at gcc dot gnu dot org
2007-06-09 22:20 ` [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); " reichelt at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-08 10:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2007-06-08 10:16 -------
Confirmed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |ice-on-invalid-code
Last reconfirmed|0000-00-00 00:00:00 |2007-06-08 10:16:34
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (2 preceding siblings ...)
2007-06-08 10:16 ` rguenth at gcc dot gnu dot org
@ 2007-06-09 22:20 ` reichelt at gcc dot gnu dot org
2007-06-29 18:41 ` mmitchel at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2007-06-09 22:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from reichelt at gcc dot gnu dot org 2007-06-09 22:20 -------
Even shorter testcase:
=================================
template<typename T> struct A
{
T& foo();
A() { foo.~T(); }
};
A<int> a;
=================================
With checking enabled I get the following crash:
bug.cc: In constructor 'A<T>::A() [with T = int]':
bug.cc:8: instantiated from here
bug.cc:5: internal compiler error: tree check: expected field_decl, have
baselink in component_ref_field_offset, at expr.c:5960
Please submit a full bug report, [etc.]
--
reichelt at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Keywords| |monitored
Summary|Compiler segmentation fault |[4.1/4.2/4.3 regression] ICE
|when trying to call x.~X(); |trying to call x.~X(); in a
|(X &x = f();) in a template |template
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (3 preceding siblings ...)
2007-06-09 22:20 ` [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); " reichelt at gcc dot gnu dot org
@ 2007-06-29 18:41 ` mmitchel at gcc dot gnu dot org
2007-11-08 11:49 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-06-29 18:41 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (4 preceding siblings ...)
2007-06-29 18:41 ` mmitchel at gcc dot gnu dot org
@ 2007-11-08 11:49 ` jakub at gcc dot gnu dot org
2007-11-10 7:36 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-08 11:49 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2007-
| |11/msg00407.html
Status|NEW |ASSIGNED
Last reconfirmed|2007-06-08 10:16:34 |2007-11-08 11:49:23
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (5 preceding siblings ...)
2007-11-08 11:49 ` jakub at gcc dot gnu dot org
@ 2007-11-10 7:36 ` jakub at gcc dot gnu dot org
2007-11-10 7:53 ` [Bug c++/32241] [4.1/4.2 " jakub at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-10 7:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2007-11-10 07:36 -------
Subject: Bug 32241
Author: jakub
Date: Sat Nov 10 07:36:09 2007
New Revision: 130066
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130066
Log:
PR c++/32241
* pt.c (tsubst_copy_and_build) <case COMPONENT_REF>: If object_type
is not scalar type, let finish_class_member_access_expr handle
diagnostics. Pass BIT_NOT_EXPR argument to
finish_pseudo_destructor_expr. Handle SCOPE_REF properly.
* g++.dg/template/pseudodtor3.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/template/pseudodtor3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.1/4.2 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (6 preceding siblings ...)
2007-11-10 7:36 ` jakub at gcc dot gnu dot org
@ 2007-11-10 7:53 ` jakub at gcc dot gnu dot org
2008-07-04 22:14 ` [Bug c++/32241] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 22:01 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-10 7:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2007-11-10 07:53 -------
Fixed so far on the trunk.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3 regression] ICE|[4.1/4.2 regression] ICE
|trying to call x.~X(); in a |trying to call x.~X(); in a
|template |template
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.2 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (7 preceding siblings ...)
2007-11-10 7:53 ` [Bug c++/32241] [4.1/4.2 " jakub at gcc dot gnu dot org
@ 2008-07-04 22:14 ` jsm28 at gcc dot gnu dot org
2009-03-30 22:01 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2008-07-04 22:13 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2 regression] ICE |[4.2 regression] ICE trying
|trying to call x.~X(); in a |to call x.~X(); in a
|template |template
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/32241] [4.2 regression] ICE trying to call x.~X(); in a template
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
` (8 preceding siblings ...)
2008-07-04 22:14 ` [Bug c++/32241] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 22:01 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 22:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jsm28 at gcc dot gnu dot org 2009-03-30 22:00 -------
Closing 4.2 branch, fixed in 4.3.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail| |4.2.5
Known to work| |4.3.0
Resolution| |FIXED
Target Milestone|4.2.5 |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-03-30 22:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-07 10:30 [Bug c++/32241] New: Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template rsalmin2 at cc dot hut dot fi
2007-06-07 10:31 ` [Bug c++/32241] " rsalmin2 at cc dot hut dot fi
2007-06-08 0:03 ` fang at csl dot cornell dot edu
2007-06-08 10:16 ` rguenth at gcc dot gnu dot org
2007-06-09 22:20 ` [Bug c++/32241] [4.1/4.2/4.3 regression] ICE trying to call x.~X(); " reichelt at gcc dot gnu dot org
2007-06-29 18:41 ` mmitchel at gcc dot gnu dot org
2007-11-08 11:49 ` jakub at gcc dot gnu dot org
2007-11-10 7:36 ` jakub at gcc dot gnu dot org
2007-11-10 7:53 ` [Bug c++/32241] [4.1/4.2 " jakub at gcc dot gnu dot org
2008-07-04 22:14 ` [Bug c++/32241] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 22:01 ` jsm28 at gcc dot gnu dot 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).