[Bug c++/39797] New: Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com
Version Info:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

Command line:
g++ --save-temp snippet.cpp
snippet.cpp:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see .

--- SOURCE CODE BEGIN ---
#include 

class MatrixBase {
public:
virtual ~MatrixBase() {}
virtual const size_t M() const = 0 ;
virtual const size_t N() const = 0 ;
} ;

template  class Matrix : public MatrixBase {
public:
Matrix() {}
~Matrix() {}
const double & operator()( size_t m, size_t n ) const {
if ( m < M && n < N ) {
return m_array[ m ][ n ] ;
} else {
throw Exception( "Matrix indices out of bounds" ) ;
}
}
Matrix & operator*=( double f ) {
for ( size_t m = 0; m < M; ++m ) {
for ( size_t n = 0; n < N; ++n ) {
m_array[ m ][ n ] *= f ;
}
}
return *this ;
}
const size_t M() const { return M ; }
const size_t N() const { return N ; }
typedef T size_type ;
private:
T m_array[ M ][ N ] ;
} ;

int main( int argc, char * argv[] )
{
 return 0 ;
}
--- SOURCE CODE END ---


-- 
   Summary: Segmentation fault g++
   Product: gcc
   Version: 4.2.4
Status: UNCONFIRMED
  Severity: critical
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stephanemarcotte at 3d-p dot com
GCC target triplet: i486-linux-gnu


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



[Bug c++/39797] Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com


--- Comment #1 from stephanemarcotte at 3d-p dot com  2009-04-17 15:27 
---
Created an attachment (id=17651)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17651&action=view)
Source file


-- 


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



[Bug c++/39797] Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com


--- Comment #2 from stephanemarcotte at 3d-p dot com  2009-04-17 15:27 
---
Created an attachment (id=17652)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17652&action=view)
the .ii file


-- 


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



[Bug c++/39797] Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com


--- Comment #3 from stephanemarcotte at 3d-p dot com  2009-04-17 15:38 
---
Isolate to the method:

Matrix::Matrix & operator*=( double f ) ...


The template takes 2 args, but the above makes g++ crash.  If I take out one
parameter (e.g., Matrix), then I get a compiler error as expected.


-- 


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



[Bug c++/39797] Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com


--- Comment #5 from stephanemarcotte at 3d-p dot com  2009-04-17 15:41 
---
Also, if I remove the derivation from the MatrixBase abstract base class, the
error disappears.


-- 


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



[Bug c++/39797] Segmentation fault g++

2009-04-17 Thread stephanemarcotte at 3d-p dot com


--- Comment #6 from stephanemarcotte at 3d-p dot com  2009-04-17 15:45 
---
the template also declares the methods M() and N(), when M, N are also template
parameters.  (The code snippet is obviously buggy.)


-- 


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