delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
From: | "Boris Schaeling" <boriss AT web DOT de> |
To: | <cygwin AT cygwin DOT com> |
Subject: | Bug in g++: Testcase exits with segmentation fault |
Date: | Mon, 13 Jan 2003 16:13:32 +0100 |
Message-ID: | <LOBBKDBPKEGJJFKNFHKBOELHIFAA.boriss@web.de> |
MIME-Version: | 1.0 |
X-Priority: | 3 (Normal) |
X-MSMail-Priority: | Normal |
Importance: | Normal |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6600 |
Note-from-DJ: | This may be spam |
------=_NextPart_000_000E_01C2BB1E.B7AEE2A0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit The testcase attached to this mail compiled with g++ 2.95.3-10 or g++ 3.2 20020927 under Cygwin 1.3.18 exits with segmentation fault. It seems to be an error in g++ as the testcase doesn't work under Linux either. Can anyone help or do I have to report this error to the GCC website? BTW I found two ways to make the testcase work: 1) Change line 64 (and 70 respectively) and use "observer *Observer" instead of "std::list<observer>". I compiled the testcase with STLport-4.5.3 under Linux to see if it's a bug in the Standard Library but got again segmentation fault. 2) Remove line 75 which is a simple "poll(NULL, 0, 2000)". It works without this line but I don't know why. Boris ------=_NextPart_000_000E_01C2BB1E.B7AEE2A0 Content-Type: application/octet-stream; name="testcase.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="testcase.cpp" /*=20 * Testcase causing segmentation fault under Cygwin and Linux=20 * Boris Schaeling (boriss AT web DOT de)=20 *=20 * Compile: g++ -otestcase testcase.cpp=20 * Run: ./testcase=20 */=20 #include <iostream>=20 #include <list>=20 extern "C" {=20 #include <poll.h>=20 }=20 /* ********** observer_base & observer ********** */=20 class observer_base=20 {=20 public:=20 virtual void run(void) { }=20 };=20 class observer : public observer_base=20 {=20 public:=20 observer();=20 void run(void) { std::cout << "Hello" << std::endl; }=20 };=20 /* ********** adapter_base & adapter ********** */=20 class adapter_base=20 {=20 protected:=20 observer_base *Observer;=20 public:=20 virtual void set_observer(observer_base *O) { Observer =3D O; }=20 virtual void run(void) { }=20 };=20 class adapter : public adapter_base=20 {=20 public:=20 void run(void) { Observer->run(); } /* <--- SEGMENTATION FAULT?! */=20 };=20 /* ********** select_data & select ********** */=20 class select_data=20 {=20 public:=20 adapter_base *Adapter;=20 select_data() { }=20 select_data(adapter_base *A) : Adapter(A) { }=20 void run(void) { Adapter->run(); }=20 };=20 class select=20 {=20 private:=20 adapter Adapter;=20 select_data Data[1];=20 std::list<observer> Observers; /* <--- CHANGE THIS TO: observer = *Observer; */=20 public:=20 select()=20 {=20 select_data data(&Adapter);=20 Data[0] =3D data;=20 Observers.push_back(observer()); /* <--- AND CHANGE THIS TO: = Observer =3D new observer; AND EVERYTHING WORKS */=20 }=20 void give(observer_base *O) { Data[0].Adapter->set_observer(O); }=20 void run(void)=20 {=20 poll(NULL, 0, 2000); /* <--- OR REMOVE THIS LINE AND EVERYTHING = WORKS */=20 Data[0].run();=20 }=20 };=20 /* ********** something else ********** */=20 class select Select;=20 observer::observer() { Select.give(this); }=20 /* ********** main ********** */=20 int main()=20 {=20 Select.run();=20 }=20 ------=_NextPart_000_000E_01C2BB1E.B7AEE2A0 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------=_NextPart_000_000E_01C2BB1E.B7AEE2A0--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |