public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39797]  New: Segmentation fault g++
@ 2009-04-17 15:26 stephanemarcotte at 3d-p dot com
  2009-04-17 15:27 ` [Bug c++/39797] " stephanemarcotte at 3d-p dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:26 UTC (permalink / raw)
  To: gcc-bugs

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 <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.2/README.Bugs>.

--- SOURCE CODE BEGIN ---
#include <stdlib.h>

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

template <class T, size_t M, size_t N> 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<T,M,N> & 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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
@ 2009-04-17 15:27 ` stephanemarcotte at 3d-p dot com
  2009-04-17 15:28 ` stephanemarcotte at 3d-p dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:27 UTC (permalink / raw)
  To: gcc-bugs



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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
  2009-04-17 15:27 ` [Bug c++/39797] " stephanemarcotte at 3d-p dot com
@ 2009-04-17 15:28 ` stephanemarcotte at 3d-p dot com
  2009-04-17 15:39 ` stephanemarcotte at 3d-p dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:28 UTC (permalink / raw)
  To: gcc-bugs



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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
  2009-04-17 15:27 ` [Bug c++/39797] " stephanemarcotte at 3d-p dot com
  2009-04-17 15:28 ` stephanemarcotte at 3d-p dot com
@ 2009-04-17 15:39 ` stephanemarcotte at 3d-p dot com
  2009-04-17 15:40 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:39 UTC (permalink / raw)
  To: gcc-bugs



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

Matrix::Matrix<T,M,N> & operator*=( double f ) ...


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


-- 


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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
                   ` (2 preceding siblings ...)
  2009-04-17 15:39 ` stephanemarcotte at 3d-p dot com
@ 2009-04-17 15:40 ` paolo dot carlini at oracle dot com
  2009-04-17 15:41 ` stephanemarcotte at 3d-p dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-04-17 15:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2009-04-17 15:40 -------
I can reproduce only with 4_2-branch (no longer maintained) and 4_3-branch. I
can't with 4_4-branch and mainline.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
                   ` (3 preceding siblings ...)
  2009-04-17 15:40 ` paolo dot carlini at oracle dot com
@ 2009-04-17 15:41 ` stephanemarcotte at 3d-p dot com
  2009-04-17 15:45 ` stephanemarcotte at 3d-p dot com
  2009-04-17 20:49 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:41 UTC (permalink / raw)
  To: gcc-bugs



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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
                   ` (4 preceding siblings ...)
  2009-04-17 15:41 ` stephanemarcotte at 3d-p dot com
@ 2009-04-17 15:45 ` stephanemarcotte at 3d-p dot com
  2009-04-17 20:49 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: stephanemarcotte at 3d-p dot com @ 2009-04-17 15:45 UTC (permalink / raw)
  To: gcc-bugs



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


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

* [Bug c++/39797] Segmentation fault g++
  2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
                   ` (5 preceding siblings ...)
  2009-04-17 15:45 ` stephanemarcotte at 3d-p dot com
@ 2009-04-17 20:49 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-04-17 20:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]



------- Comment #7 from rguenth at gcc dot gnu dot org  2009-04-17 20:49 -------
g++-4.3 -S t.C
t.C:21: error: could not convert template argument ‘MatrixBase::M’ to ‘unsigned
int’
t.C:21: error: could not convert template argument ‘MatrixBase::N’ to ‘unsigned
int’
t.C: In member function ‘const double& Matrix<T, M, N>::operator()(size_t,
size_t) const’:
t.C:18: error: there are no arguments to ‘Exception’ that depend on a template
parameter, so a declaration of ‘Exception’ must be available
t.C:18: error: (if you use ‘-fpermissive’, G++ will accept your code, but
allowing the use of an undeclared name is deprecated)

this ice-on-invalid is fixed in 4.3.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.3.3
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2009-04-17 20:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 15:26 [Bug c++/39797] New: Segmentation fault g++ stephanemarcotte at 3d-p dot com
2009-04-17 15:27 ` [Bug c++/39797] " stephanemarcotte at 3d-p dot com
2009-04-17 15:28 ` stephanemarcotte at 3d-p dot com
2009-04-17 15:39 ` stephanemarcotte at 3d-p dot com
2009-04-17 15:40 ` paolo dot carlini at oracle dot com
2009-04-17 15:41 ` stephanemarcotte at 3d-p dot com
2009-04-17 15:45 ` stephanemarcotte at 3d-p dot com
2009-04-17 20:49 ` rguenth 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).