public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62003] New: Possible bug in std::complex
@ 2014-08-03 22:38 wilczak at ii dot uj.edu.pl
  2014-08-04  9:27 ` [Bug c++/62003] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: wilczak at ii dot uj.edu.pl @ 2014-08-03 22:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003

            Bug ID: 62003
           Summary: Possible bug in std::complex
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wilczak at ii dot uj.edu.pl

Dear MinGW users,
I have found a strange behaviour of std::complex class with double template
parameter. The program given below causes segfault (gcc-4.8.1-4, Windows) when
compiled with -O1 or -O2 flag. 

The output of the program is given below (note that the second column equal to
e=v.end() should be constant).

No errors when:
- typedef Complex=double
- parameter -O0 is used
- volatile added to definition of iterator 'e' 
volatile Vector::iterator e = u.end();
- type of variable 'p' is changed to double instead of Complex 

Daniel Wilczak

// ###########################
// Output

0x3f19b0 0x3f1a40 (0,0)
0x3f19c0 0x3f1a40 (0,0)
0x3f19d0 0x3f1a40 (0,0)
0x3f19e0 0 (0,0)
0x3f19f0 0 (0,0)
0x3f1a00 0x40000000 (0,0)
0x3f1a10 0 (0,0)
0x3f1a20 0 (0,0)
0x3f1a30 0x1 (0,0)
0x3f1a40 0x405064 (2.06124e-309,3.4598e-307)
0x3f1a50 0x6fcc43c0 (0,4.24399e-314)
0x3f1a60 0x4038dd (2.04322e-317,3.711e+261)
0x3f1a70 0x28fee8 (1.73018e-307,2.47437e+261)

// ###########################
// The program 

#include <iostream>
#include <complex>

template<class T>
struct V{
  typedef T* iterator;
  iterator begin() { return data; }
  iterator end() { return data+capacity; }
  V(unsigned c) : capacity(c) { data = new T[c]; }
  ~V(){ delete[] data; }
  T *data;
  unsigned capacity;
};

int main()
{
  typedef std::complex<double> Complex;
  typedef V<Complex> Vector;
  Vector u(9);
  Vector::iterator j = u.begin();
  Vector::iterator e = u.end();
  for(; j!=e; ++j) {
    Complex p(2.,0.);
    Complex q = *j;
    Complex z = q*p;
    std::cout << j << " " << e << " " << z << std::endl;
  }
  return 0;
}


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

* [Bug c++/62003] Possible bug in std::complex
  2014-08-03 22:38 [Bug c++/62003] New: Possible bug in std::complex wilczak at ii dot uj.edu.pl
@ 2014-08-04  9:27 ` redi at gcc dot gnu.org
  2014-08-04 11:31 ` wilczak at ii dot uj.edu.pl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2014-08-04  9:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-08-04
            Version|unknown                     |4.8.1
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please provide the output of 'gcc -v' as requested at http://gcc.gnu.org/bugs


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

* [Bug c++/62003] Possible bug in std::complex
  2014-08-03 22:38 [Bug c++/62003] New: Possible bug in std::complex wilczak at ii dot uj.edu.pl
  2014-08-04  9:27 ` [Bug c++/62003] " redi at gcc dot gnu.org
@ 2014-08-04 11:31 ` wilczak at ii dot uj.edu.pl
  2014-08-04 11:33 ` redi at gcc dot gnu.org
  2014-08-04 11:38 ` wilczak at ii dot uj.edu.pl
  3 siblings, 0 replies; 5+ messages in thread
From: wilczak at ii dot uj.edu.pl @ 2014-08-04 11:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003

--- Comment #2 from Daniel Wilczak <wilczak at ii dot uj.edu.pl> ---
OS version Windows 7, 64-bit.
gcc version:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32
--build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld
--enable-lto --enable-libssp --disable-multilib
--enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions
--with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug
--enable-version-specific-runtime-libs
--with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld
--with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr=
--with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp
--enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw
--disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)


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

* [Bug c++/62003] Possible bug in std::complex
  2014-08-03 22:38 [Bug c++/62003] New: Possible bug in std::complex wilczak at ii dot uj.edu.pl
  2014-08-04  9:27 ` [Bug c++/62003] " redi at gcc dot gnu.org
  2014-08-04 11:31 ` wilczak at ii dot uj.edu.pl
@ 2014-08-04 11:33 ` redi at gcc dot gnu.org
  2014-08-04 11:38 ` wilczak at ii dot uj.edu.pl
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2014-08-04 11:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |mingw32
             Status|WAITING                     |UNCONFIRMED
     Ever confirmed|1                           |0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I can't reproduce this on GNU/Linux, so it might be a target issue.


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

* [Bug c++/62003] Possible bug in std::complex
  2014-08-03 22:38 [Bug c++/62003] New: Possible bug in std::complex wilczak at ii dot uj.edu.pl
                   ` (2 preceding siblings ...)
  2014-08-04 11:33 ` redi at gcc dot gnu.org
@ 2014-08-04 11:38 ` wilczak at ii dot uj.edu.pl
  3 siblings, 0 replies; 5+ messages in thread
From: wilczak at ii dot uj.edu.pl @ 2014-08-04 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003

--- Comment #4 from Daniel Wilczak <wilczak at ii dot uj.edu.pl> ---
Me neither - on GNU/Linux the program runs normally.
Daniel

W dniu 2014-08-04 13:32, redi at gcc dot gnu.org pisze:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62003
>
> Jonathan Wakely <redi at gcc dot gnu.org> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>               Target|                            |mingw32
>               Status|WAITING                     |UNCONFIRMED
>       Ever confirmed|1                           |0
>
> --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> I can't reproduce this on GNU/Linux, so it might be a target issue.
>


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

end of thread, other threads:[~2014-08-04 11:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-03 22:38 [Bug c++/62003] New: Possible bug in std::complex wilczak at ii dot uj.edu.pl
2014-08-04  9:27 ` [Bug c++/62003] " redi at gcc dot gnu.org
2014-08-04 11:31 ` wilczak at ii dot uj.edu.pl
2014-08-04 11:33 ` redi at gcc dot gnu.org
2014-08-04 11:38 ` wilczak at ii dot uj.edu.pl

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