public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: problem with dynamic_cast
@ 2000-09-08  7:10 Earnie Boyd
  2000-09-08  8:04 ` Kris Thielemans
  0 siblings, 1 reply; 19+ messages in thread
From: Earnie Boyd @ 2000-09-08  7:10 UTC (permalink / raw)
  To: Larry Hall (RFK Partners, Inc), Fleischer, Karsten (K.),
	'kris.thielemans@ic.ac.uk'
  Cc: Cygwin (E-mail)

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

--- "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com> wrote:
> Quite true.  -lm and -lc are not necessary with Cygwin.  The support for 
> them are in the Cygwin DLL/lib which is linked in automatically.  Linking
> with it twice (or more) guarantees a crash.  The simple answer is, don't
> us -lm or -lc with Cygwin.
> 

My suggestion to this problem:

Replace the symbolic links with stub libraries.  I've attached them for your
convenience.  With the stub libraries it won't matter if you forget to not use
-lm or -lc 'cause things will work correctly.

Cheers,

=====
--- < http://earniesystems.safeshopper.com > ---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://gw32.freeyellow.com/ >
           __Minimalist GNU for Windows__
  Mingw32 List: < http://www.egroups.com/group/mingw32/ >
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
libc.a
libm.a
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


[-- Attachment #2: libc.a --]
[-- Type: application/x-archive, Size: 490 bytes --]

[-- Attachment #3: libm.a --]
[-- Type: application/x-archive, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: problem with dynamic_cast
@ 2000-09-08  7:21 Bernard Dautrevaux
  0 siblings, 0 replies; 19+ messages in thread
From: Bernard Dautrevaux @ 2000-09-08  7:21 UTC (permalink / raw)
  To: 'Larry Hall (RFK Partners, Inc)', Fleischer, Karsten (K.),
	'kris.thielemans@ic.ac.uk'
  Cc: Cygwin (E-mail)

> -----Original Message-----
> From: Larry Hall (RFK Partners, Inc) [ mailto:lhall@rfk.com ]
> Sent: Friday, September 08, 2000 3:53 PM
> To: Fleischer, Karsten (K.); 'kris.thielemans@ic.ac.uk'
> Cc: Cygwin (E-mail)
> Subject: RE: problem with dynamic_cast
> 
> 
> Quite true.  -lm and -lc are not necessary with Cygwin.  The 
> support for 
> them are in the Cygwin DLL/lib which is linked in 
> automatically.  Linking
> with it twice (or more) guarantees a crash.  The simple 
> answer is, don't
> us -lm or -lc with Cygwin.
> 

Obviously if I create a program to work on cygwin, I'll be careful not to
add "-lm" to my link commands; however I quite often just port UNIX programs
to cygwin and then I may forget to remove "-lm" from the makefiles (or
oversee them). 

Just saying "dont use -lm" is a bit harsh on the developper; at the least we
should avoid delivering libm.a, so we will get a clear message "libm.a" not
found, that could be looked up in the FAQ quite simply. Now we just link
correctly but then crash misteriously ;-(

I think I remember someone already suggest a simple solution to the fact the
"-lm" crash under cygwin but it seems it was never implemented :-( :

Instead of having libm.a (and libc.a BTW) be a symbolic link to libcygwin.a,
just create one (two) empty libraries named "libm.a" and "libc.a"; linking
several times to these libraries would then essentially do nothing, which is
what we expect, instead of creating a "crashing" executable :-)

Maybe I'm just tood tosee the obvious problem this causes that will prevent
cygwin to be useful :-)

I know I should provide a patch, but I just don't know where to look :-)

Just my 2 cents,

	Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux@microprocess.com
		b.dautrevaux@usa.net
-------------------------------------------- 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: problem with dynamic_cast
@ 2000-09-08  7:19 Fleischer, Karsten (K.)
  2000-09-08  9:47 ` Chris Faylor
  0 siblings, 1 reply; 19+ messages in thread
From: Fleischer, Karsten (K.) @ 2000-09-08  7:19 UTC (permalink / raw)
  To: 'Earnie Boyd'; +Cc: Cygwin (E-mail)

How about including the stub libraries in the distribution, rather than the
symlinks?


> -----Original Message-----
> From: Earnie Boyd [ mailto:earnie_boyd@yahoo.com ]
> Sent: Freitag, 8. September 2000 15:11
> To: Larry Hall (RFK Partners, Inc); Fleischer, Karsten (K.);
> 'kris.thielemans@ic.ac.uk'
> Cc: Cygwin (E-mail)
> Subject: RE: problem with dynamic_cast
> 
> 
> --- "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com> wrote:
> > Quite true.  -lm and -lc are not necessary with Cygwin.  
> The support for 
> > them are in the Cygwin DLL/lib which is linked in 
> automatically.  Linking
> > with it twice (or more) guarantees a crash.  The simple 
> answer is, don't
> > us -lm or -lc with Cygwin.
> > 
> 
> My suggestion to this problem:
> 
> Replace the symbolic links with stub libraries.  I've 
> attached them for your
> convenience.  With the stub libraries it won't matter if you 
> forget to not use
> -lm or -lc 'cause things will work correctly.
> 
> Cheers,
> 
> =====
> --- < http://earniesystems.safeshopper.com > ---
>    Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
>             __Cygwin: POSIX on Windows__
> Cygwin Newbies: < http://gw32.freeyellow.com/ >
>            __Minimalist GNU for Windows__
>   Mingw32 List: < http://www.egroups.com/group/mingw32/ >
>     Mingw Home: < http://www.mingw.org/ >
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: problem with dynamic_cast
@ 2000-09-08  6:13 Fleischer, Karsten (K.)
  0 siblings, 0 replies; 19+ messages in thread
From: Fleischer, Karsten (K.) @ 2000-09-08  6:13 UTC (permalink / raw)
  To: 'kris.thielemans@ic.ac.uk'; +Cc: Cygwin (E-mail)

> -----Original Message-----
> From: Kris Thielemans [ mailto:kris.thielemans@ic.ac.uk ]
> Sent: Freitag, 8. September 2000 13:54
> To: Fleischer, Karsten (K.)
> Cc: Cygwin (E-mail)
> Subject: RE: problem with dynamic_cast
> 
> 
> 
> Dear Karsten,
> 
> yes, that's seems to be it. Many thanks !
> 
> I also found the relevant emails in the archive now (I was 
> looking for RTTI
> and dynamic_cast, but the relevant mails didn't mention those).
> 
> For those interested, you could start with:
> http://www.delorie.com/archives/thread.cgi?msg=cygwin/2000/05/
> 31/19:11:09
> 
> 
> It would be wonderful if somebody could provide me with a patched gcc,
> and/or update the distribution.


Yes, indeed! A patch would be nice. Even if you keep the simple rule "Don't
link with -lm/-lc" in mind, you sometimes forget about it :-)
Scanning old makefiles for these isn't fun at all either.


> 
> Thanks again,
> 
> Kris
> 
> 
> > Hi Kris,
> >
> > I didn't look at your example, but I think you shouldn't use -lm
> > (and -lc).
> > libm.a/libc.a are symlinked to libcygwin.a and this is linked
> > against every
> > program by default. I ran into troubles and stackdumps too, 
> when linking
> > with -lm. I think there's more about this problem in the archives.
> >
> > Karsten
> >
> 
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
[parent not found: <B0016139757@mzdy10.allegro.net>]
* RE: problem with dynamic_cast
@ 2000-09-08  4:58 Fleischer, Karsten (K.)
  2000-09-08  6:56 ` Larry Hall (RFK Partners, Inc)
  0 siblings, 1 reply; 19+ messages in thread
From: Fleischer, Karsten (K.) @ 2000-09-08  4:58 UTC (permalink / raw)
  To: 'kris.thielemans@ic.ac.uk'; +Cc: Cygwin (E-mail)

Hi Kris,

I didn't look at your example, but I think you shouldn't use -lm (and -lc).
libm.a/libc.a are symlinked to libcygwin.a and this is linked against every
program by default. I ran into troubles and stackdumps too, when linking
with -lm. I think there's more about this problem in the archives.

Karsten

> -----Original Message-----
> From: Kris Thielemans [ mailto:kris.thielemans@ic.ac.uk ]
> Sent: Freitag, 8. September 2000 12:46
> To: Gnuwin
> Cc: gcc-bugs@gcc.gnu.org
> Subject: RE: problem with dynamic_cast
> 
> 
> 
> 
> > -----Original Message-----
> > From: Chris Faylor [ mailto:cgf@cygnus.com ]
> > Sent: 07 September 2000 17:01
> > To: Gnuwin
> > Cc: kris.thielemans@csc.mrc.ac.uk
> > Subject: Re: problem with dynamic_cast
> >
> >
> > This is a c++ problem.  You should probably report this to a c++
> > mailing list.
> 
> I doubt it really, but I send this to a C++ mailing list 
> anyway. I've been
> able to boil it down to something really simple. If the latest gcc
> distribution is that broken, we're all in trouble.
> 
> Summarising: in cygwin 1.1.4, or the gcc (or ld) distributed 
> with it (I've
> installed 1.1.4 yesterday), there is a conflict with using 
> RTTI and using
> the math library.
> 
> 
> Attached is a VERY simple C++ program that uses RTTI, but 
> nothing else.
> Compile it with
> 
> g++ dynamic_cast.cxx -lm
> 
> When you run it, it crashes in the dynamic_cast statement. On 
> the other
> hand, compile it with
> 
> g++ dynamic_cast.cxx
> 
> -> it runs fine (i.e. does essentially nothing).
> 
> 
> 
> 
> More details:
> 
> I'm running NT 4.0 sp5 and cygwin 1.1.4.
> 
> screendump of running g++ -v:
> 
> $ g++ dynamic_cast.cxx -lm -v
> Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/specs
> gcc version 2.95.2 19991024 (release-2)
> 
> /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/cpp.exe -lang-c++ -v 
> -D__GNUC__=2 -D_
> _GN
> UG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Di386 -D_X86=1 
> -D__STDC__=1 -D__st
> dcal
> l=__attribute__((__stdcall__)) 
> -D__cdecl=__attribute__((__cdecl__)) -D__decl
> spec
> (x)=__attribute__((x)) -D__i386__ -D_X86=1 -D__STDC__=1 
> -D__stdcall=__attrib
> ute_
> _((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) 
> -D__declspec(x)=__attr
> ibut
> e__((x)) -D__i386 -Asystem(winnt) -Acpu(i386) -Amachine(i386) 
> -D__EXCEPTIONS
>  -re
> map -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ 
> -Di686 -Dpentiump
> ro -
> D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ 
> -D__CYGWIN32__ -D__CYGWIN
> __ -
> Dunix -D_WIN32 -DWINNT dynamic_cast.cxx /cygdrive/c/TMP/ccpF3zVU.ii
> GNU CPP version 2.95.2 19991024 (release-2) (80386, BSD syntax)
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/include
>  /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/../../../../include/g++-3
>  /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/../../../../include
>  /usr/include
>  /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/include
>  /usr/include
> End of search list.
> The following default directories have been omitted from the 
> search path:
>  /usr/include/g++
>  /usr/X11R6.4/include
>  /usr/local/include
> End of omitted list.
>  /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/cc1plus.exe
> /cygdrive/c/TMP/ccpF3zVU.ii
> -quiet -dumpbase dynamic_cast.cc -version -o 
> /cygdrive/c/TMP/ccKbIuaN.s
> GNU C++ version 2.95.2 19991024 (release-2) (i686-pc-cygwin) 
> compiled by GNU
> C v
> ersion 2.95.2 19991024 (release-2).
>  as -o /cygdrive/c/TMP/cc7g2nmV.o /cygdrive/c/TMP/ccKbIuaN.s
>  /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/collect2.exe -Bdynamic
> /usr/lib/crt0.o -
> L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2
> /cygdrive/c/TMP/cc7g2nmV.o -lstdc++ -lm
> -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
> 
> ld.dump attached is a screendump from running ld --verbose 
> explicitly, after
> removing as much libraries and options I could, while still 
> reproducing the
> crash.
> 
> 
> gdb.dump is a screendump from running gdb on the file
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: problem with dynamic_cast
@ 2000-09-07  8:52 Kris Thielemans
  2000-09-07  9:02 ` Chris Faylor
  0 siblings, 1 reply; 19+ messages in thread
From: Kris Thielemans @ 2000-09-07  8:52 UTC (permalink / raw)
  To: Gnuwin

[-- Attachment #1: Type: text/plain, Size: 4039 bytes --]

Hi,

I have a tiny bit more information on this problem.

- I reproduced it on my own NT box, with cygwin 1.1.4 (it does NOT happen
with B20.1)

- I can reproduce it with a file (attached) that does not need linking with
any other file (except standard libs).
* If I do a normal "g++ dynamic_cast8.cxx", the program runs fine
* If I link it with another file I have "g++ dynamic_cast8.cxx bla.o" it
crashes.

The other file is also compiled with the same gcc (it's not specific to
which file exactly).


Weird.

Suggestions ?

Kris


> -----Original Message-----
> From: Kris Thielemans [ mailto:kris.thielemans@ic.ac.uk ]
> Sent: 31 August 2000 15:58
> To: Gnuwin
> Subject: problem with dynamic_cast
>
>
> Hi,
>
> I have a problem with some of our own C++ software when compiled
> with gcc on cygwin cygwin v.1.1.4 on Windows NT4.00.1381 (Finnish
> language). Note that this program runs fine on my own NT 4.0 sp5
> or sp6 machines running cygwin B20.1 with gcc 2.95.2, and on
> Solaris with gcc 2.95.2, and on AIX with gcc 2.8.1).
>
> The problem occurs when executing a dynamic_cast on a pointer.
> Any suggestions ?
>
>
> details:
> ---------
> The program generates the following error:
>    0 [main] test_VoxelsOnCartesianGrid 1039 handle_exceptions: Exception:
> STATUS_ACCESS_VIOLATION
>    974 [main] test_VoxelsOnCartesianGrid 1039 stackdump: Dumping
> stack trace
> to test_VoxelsOnCartesianGrid.exe.stackdump
> make: *** [run_tests] Segmentation fault (core dumped)
>
> The file where it crashes is compiled as follows:
> g++  -g -D_DEBUG -g  -Wall  -I/home/PPhead/include  -o
> debug/VoxelsOnCartesianGrid.o -c VoxelsOnCartesianGrid.cxx
>
>
> When running the program in gdb, the stack trace after the crash is:
> Program received signal SIGSEGV, Segmentation fault.
> 0x611e4 in ?? ()
> (gdb) info stack
> #0  0x611e4 in ?? ()
> #1  0x41e484 in __si_type_info::dcast (this=0x460520, to=@0x4604c0,
>     require_public=1, addr=0xa057e90, sub=0x460280, subptr=0xa057e90)
>     at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76
> #2  0x41e6d3 in __dynamic_cast (
>     from=0x441658 <Tomo::ProjDataInfoCylindricalArcCorr type_info
> function>,
>     to=0x4415a4 <Tomo::ProjDataInfoCylindrical type_info function>,
>     require_public=1, address=0xa057e90,
>     sub=0x441544 <Tomo::ProjDataInfo type_info function>,
> subptr=0xa057e90)
>     at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38
> #3  0x40ddda in Tomo::find_sampling_and_z_size (z_sampling=@0x266f898,
>     s_sampling=@0x266f894, z_size=@0x266f89c,
> proj_data_info_ptr=0xa057e90)
>     at VoxelsOnCartesianGrid.cxx:45
> #4  0x4325e8 in
> Tomo::VoxelsOnCartesianGrid<float>::VoxelsOnCartesianGrid (
>     this=0x266fc00, proj_data_info=@0xa057e90, zoom=2.29999995,
>     origin=@0x266fd10, make_xy_size_odd=false) at
> VoxelsOnCartesianGrid.cxx:138
> #5  0x4022a6 in Tomo::VoxelsOnCartesianGridTests::run_tests
> (this=0x266fd60)
>     at test_VoxelsOnCartesianGrid.cxx:103
> #6  0x403174 in main () at test_VoxelsOnCartesianGrid.cxx:180
> #7  0x61002272 in _size_of_stack_reserve__ ()
> #8  0x61002805 in _size_of_stack_reserve__ ()
> #9  0x61002843 in _size_of_stack_reserve__ ()
> #10 0x41cdd5 in cygwin_crt0 ()
>
>
> This seems to say there is something wrong in the dynamic_cast
> statement on that line, which looks as follows:
>   if (const ProjDataInfoCylindrical*
>         proj_data_info_cyl_ptr =
> 	dynamic_cast<const ProjDataInfoCylindrical*>(proj_data_info_ptr))
>   { ...}
>
> By the way, if you check the stack trace, you'll see that the
> dynamic cast is from a ProjDataInfoCylindricalArcCorr * to a
> ProjDataInfoCylindrical *, where ProjDataInfoCylindricalArcCorr
> is derived from ProjDataInfoCylindrical. (Not that it should
> crash in any case).
>
>
> Thanks !
>
>
>
> Kris Thielemans
> (kris.thielemans@ic.ac.uk)
> MRC Cyclotron Unit,
> Hammersmith Hospital,
> DuCane Rd,London W12 0NN, United Kingdom
>
> Phone on :   +44 (020)8383 3731
> FAX on :     +44 (020)8383 2029
>
> NEW web site address:
> http://www.cu.mrc.ac.uk/~kris

[-- Attachment #2: dynamic_cast8.cxx --]
[-- Type: text/x-c++, Size: 5730 bytes --]

#define END_NAMESPACE_TOMO
#define START_NAMESPACE_TOMO
#define USING_NAMESPACE_TOMO

 
template <class NUMBER> 
inline NUMBER square(const NUMBER &x) { return x*x; }

#include <iostream>

#ifndef __ProjDataInfo_H__
#define __ProjDataInfo_H__



START_NAMESPACE_TOMO

template <typename elemT> class Sinogram;
template <typename elemT> class Viewgram;
template <typename elemT> class SegmentByView;
template <typename elemT> class SegmentBySinogram;
template <typename elemT> class RelatedViewgrams;
class DataSymmetriesForViewSegmentNumbers;
class ViewSegmentNumbers;
class PMessage;

class ProjDataInfo
{
  
public:

  
  
  /************ constructors ***********/
  // TODO should probably be protected

  //! Construct an empty object
  inline  ProjDataInfo();


  //! Standard trick for a 'virtual copy-constructor' 
  virtual ProjDataInfo* clone() const = 0;

  //! Destructor
  virtual ~ProjDataInfo() {}

  /**************** member functions *********/

  // TODOdoc coordinate system
  //! Get tangent of the co-polar angle, tan(theta)
  virtual float get_tantheta(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const =0;
  //! Get azimuthal angle phi
  virtual float get_phi(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const =0;
  
  //! Get value of the (roughly) axial coordinate in the projection plane (in mm)
  virtual float get_t(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const =0;

  //! Get value of the tangential coordinate in the projection plane (in mm)
  virtual float get_s(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const =0;
  
  
private:

  int min_view_num;
  int max_view_num;
  int min_tangential_pos_num;
  int max_tangential_pos_num;
  
};

END_NAMESPACE_TOMO

//#include "ProjDataInfo.inl"
//
// @(#)ProjDataInfo.inl	1.1: 00/06/14
//

START_NAMESPACE_TOMO


ProjDataInfo::ProjDataInfo()
{}
  


END_NAMESPACE_TOMO


#endif //  __ProjDataInfo_H__

#ifndef __ProjDataInfoCylindrical_H__
#define __ProjDataInfoCylindrical_H__


//#include"ProjDataInfo.h"

START_NAMESPACE_TOMO
/*!
  \ingroup buildblock 
  \brief projection data info for data corresponding to a 
  'cylindrical' sampling.

  These data are organised by ring differences (allowing for
  merging of some ring differences into 1 segment). It is general
  enough to have both the CTI 'spanned' format, and the GE Advance
  format.
*/
// TODOdoc more
class ProjDataInfoCylindrical: public ProjDataInfo
{

public:
  //! Constructors
  inline ProjDataInfoCylindrical();
		       
  inline float get_phi(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const; 
 
  inline float get_t(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const;



protected:

  float azimuthal_angle_sampling;
  float ring_radius;

private:
  float ring_spacing;

};


END_NAMESPACE_TOMO

//#include "ProjDataInfoCylindrical.inl"

//
// @(#)ProjDataInfoCylindrical.inl	1.1: 00/06/14
//
START_NAMESPACE_TOMO

ProjDataInfoCylindrical::ProjDataInfoCylindrical()
{}


float
ProjDataInfoCylindrical::get_phi(int segment_num,int view_num,int axial_position_num, int transaxial_position_num)const
{ return view_num*azimuthal_angle_sampling;}

float
ProjDataInfoCylindrical::get_t(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const
{return axial_position_num;}





END_NAMESPACE_TOMO


  

#endif

#ifndef __ProjDataInfoCylindricalArcCorr_H__
#define __ProjDataInfoCylindricalArcCorr_H__


//#include "ProjDataInfoCylindrical.h"

START_NAMESPACE_TOMO

/*!
  \ingroup buildblock 
  \brief projection data info for arc-corrected data
  */
class ProjDataInfoCylindricalArcCorr : public ProjDataInfoCylindrical
{

public:
  //! Constructors
  inline ProjDataInfoCylindricalArcCorr();

  
  inline virtual float get_tantheta(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const; 
  inline virtual float get_s(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const;
  inline ProjDataInfo* clone() const;

private:
  
  float bin_size;
  

};

END_NAMESPACE_TOMO

//#include "ProjDataInfoCylindricalArcCorr.inl"

//
// @(#)ProjDataInfoCylindricalArcCorr.inl	1.1: 00/06/14
//

START_NAMESPACE_TOMO
ProjDataInfoCylindricalArcCorr:: ProjDataInfoCylindricalArcCorr()

{}

float
ProjDataInfoCylindricalArcCorr::get_s(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const
{return transaxial_position_num*bin_size;}


float
ProjDataInfoCylindricalArcCorr::get_tantheta(int segment_num,int view_num,int axial_position_num, int transaxial_position_num) const
{
  return
    (2*sqrt(square(ring_radius)-square(get_s(segment_num,view_num,axial_position_num, transaxial_position_num))));
  
}





ProjDataInfo*
ProjDataInfoCylindricalArcCorr::clone() const
{
 return static_cast<ProjDataInfo*>(new ProjDataInfoCylindricalArcCorr(*this));

}


END_NAMESPACE_TOMO


#endif

//#include "ProjDataInfoCylindricalArcCorr.h"


USING_NAMESPACE_TOMO

// a local help function to find appropriate sizes etc.

static void find_sampling_and_z_size(
				 const ProjDataInfo* proj_data_info_ptr)
{

  // first z- things

  const ProjDataInfoCylindrical*
        proj_data_info_cyl_ptr = 
    dynamic_cast<const ProjDataInfoCylindrical*>(proj_data_info_ptr);

  if (proj_data_info_cyl_ptr)
   {
     std::cerr << "OK !\n";
   }
  else
    {
      std::cerr << " Not OK!\n";
    }
}


int main()
{

  ProjDataInfo * proj_data_info_ptr = 
    new ProjDataInfoCylindricalArcCorr;

  find_sampling_and_z_size(proj_data_info_ptr);
  return 0;

}




^ permalink raw reply	[flat|nested] 19+ messages in thread
* problem with dynamic_cast
@ 2000-08-31  8:01 Kris Thielemans
  0 siblings, 0 replies; 19+ messages in thread
From: Kris Thielemans @ 2000-08-31  8:01 UTC (permalink / raw)
  To: Gnuwin

Hi,

I have a problem with some of our own C++ software when compiled with gcc on
cygwin cygwin v.1.1.4 on Windows NT4.00.1381 (Finnish language). Note that
this program runs fine on my own NT 4.0 sp5 or sp6 machines running cygwin
B20.1 with gcc 2.95.2, and on Solaris with gcc 2.95.2, and on AIX with gcc
2.8.1).

The problem occurs when executing a dynamic_cast on a pointer.
Any suggestions ?


details:
---------
The program generates the following error:
   0 [main] test_VoxelsOnCartesianGrid 1039 handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
   974 [main] test_VoxelsOnCartesianGrid 1039 stackdump: Dumping stack trace
to test_VoxelsOnCartesianGrid.exe.stackdump
make: *** [run_tests] Segmentation fault (core dumped)

The file where it crashes is compiled as follows:
g++  -g -D_DEBUG -g  -Wall  -I/home/PPhead/include  -o
debug/VoxelsOnCartesianGrid.o -c VoxelsOnCartesianGrid.cxx


When running the program in gdb, the stack trace after the crash is:
Program received signal SIGSEGV, Segmentation fault.
0x611e4 in ?? ()
(gdb) info stack
#0  0x611e4 in ?? ()
#1  0x41e484 in __si_type_info::dcast (this=0x460520, to=@0x4604c0,
    require_public=1, addr=0xa057e90, sub=0x460280, subptr=0xa057e90)
    at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76
#2  0x41e6d3 in __dynamic_cast (
    from=0x441658 <Tomo::ProjDataInfoCylindricalArcCorr type_info function>,
    to=0x4415a4 <Tomo::ProjDataInfoCylindrical type_info function>,
    require_public=1, address=0xa057e90,
    sub=0x441544 <Tomo::ProjDataInfo type_info function>, subptr=0xa057e90)
    at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38
#3  0x40ddda in Tomo::find_sampling_and_z_size (z_sampling=@0x266f898,
    s_sampling=@0x266f894, z_size=@0x266f89c, proj_data_info_ptr=0xa057e90)
    at VoxelsOnCartesianGrid.cxx:45
#4  0x4325e8 in Tomo::VoxelsOnCartesianGrid<float>::VoxelsOnCartesianGrid (
    this=0x266fc00, proj_data_info=@0xa057e90, zoom=2.29999995,
    origin=@0x266fd10, make_xy_size_odd=false) at
VoxelsOnCartesianGrid.cxx:138
#5  0x4022a6 in Tomo::VoxelsOnCartesianGridTests::run_tests (this=0x266fd60)
    at test_VoxelsOnCartesianGrid.cxx:103
#6  0x403174 in main () at test_VoxelsOnCartesianGrid.cxx:180
#7  0x61002272 in _size_of_stack_reserve__ ()
#8  0x61002805 in _size_of_stack_reserve__ ()
#9  0x61002843 in _size_of_stack_reserve__ ()
#10 0x41cdd5 in cygwin_crt0 ()


This seems to say there is something wrong in the dynamic_cast statement on
that line, which looks as follows:
  if (const ProjDataInfoCylindrical*
        proj_data_info_cyl_ptr =
	dynamic_cast<const ProjDataInfoCylindrical*>(proj_data_info_ptr))
  { ...}

By the way, if you check the stack trace, you'll see that the dynamic cast
is from a ProjDataInfoCylindricalArcCorr * to a ProjDataInfoCylindrical *,
where ProjDataInfoCylindricalArcCorr is derived from
ProjDataInfoCylindrical. (Not that it should crash in any case).


Thanks !



Kris Thielemans
(kris.thielemans@ic.ac.uk)
MRC Cyclotron Unit,
Hammersmith Hospital,
DuCane Rd,London W12 0NN, United Kingdom

Phone on :   +44 (020)8383 3731
FAX on :     +44 (020)8383 2029

NEW web site address:
http://www.cu.mrc.ac.uk/~kris


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

end of thread, other threads:[~2000-10-04 15:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-08  7:10 problem with dynamic_cast Earnie Boyd
2000-09-08  8:04 ` Kris Thielemans
  -- strict thread matches above, loose matches on Subject: below --
2000-09-08  7:21 Bernard Dautrevaux
2000-09-08  7:19 Fleischer, Karsten (K.)
2000-09-08  9:47 ` Chris Faylor
2000-09-08 20:01   ` Chris Faylor
2000-09-12  6:55     ` David Starks-Browning
2000-09-12  7:07       ` Chris Faylor
2000-10-04 15:20     ` Chris Faylor
2000-09-08  6:13 Fleischer, Karsten (K.)
     [not found] <B0016139757@mzdy10.allegro.net>
2000-09-08  5:56 ` Kris Thielemans
2000-09-08  4:58 Fleischer, Karsten (K.)
2000-09-08  6:56 ` Larry Hall (RFK Partners, Inc)
2000-09-08  7:04   ` Kris Thielemans
2000-09-08  7:16     ` Larry Hall (RFK Partners, Inc)
2000-09-07  8:52 Kris Thielemans
2000-09-07  9:02 ` Chris Faylor
2000-09-08  4:48   ` Kris Thielemans
2000-08-31  8:01 Kris Thielemans

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).