octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MSVC compilation patch: OCTAVE_LOCAL_BUFFER


From: michael . goffioul
Subject: MSVC compilation patch: OCTAVE_LOCAL_BUFFER
Date: Thu, 09 Nov 2006 15:20:21 +0100

Creating a 0-sized std::vector and accessing its first element produces a crash under
MSVC. The attached patch solves it. I didn't use any #ifdef as it looks safer under any
system.
 
Michael.
 
Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.544
diff -c -p -r1.544 configure.in
*** configure.in        6 Nov 2006 17:52:52 -0000       1.544
--- configure.in        9 Nov 2006 14:16:30 -0000
*************** typedef int sig_atomic_t;
*** 1920,1926 ****
 
  #define OCTAVE_LOCAL_BUFFER(T, buf, size) \\
    std::vector< T > buf ## _vector (size); \\
!   T *buf = &(buf ## _vector[0])
 
  /* #endif */
 
--- 1920,1926 ----
 
  #define OCTAVE_LOCAL_BUFFER(T, buf, size) \\
    std::vector< T > buf ## _vector (size); \\
!   T *buf = ( (size) > 0 ? &(buf ## _vector[0]) : NULL )
 
  /* #endif */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]