[Bug libstdc++/90050] std::filesystem::path segfault in destructor

2019-04-16 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050

--- Comment #6 from Mihai Preda  ---
OK, thanks.

So if on Ubuntu 19.04, the default compiler produces without errors/warnings,
from valid source code, an executable that crashes, that's programmer error?!

I understand the explanation, but there is a problem. Maybe the bug is not with
gcc but with Ubuntu, but a bug there is.

[Bug libstdc++/90050] std::filesystem::path segfault in destructor

2019-04-13 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050

--- Comment #2 from Mihai Preda  ---
Adding -lstdc++fs fixes the problem with g++ 8.3

g++-9 does not segfault even without -lstdc++fs

g++-9 --version
g++-9 (Ubuntu 9-20190402-1ubuntu1) 9.0.1 20190402 (experimental) [trunk
revision 270074]

[Bug libstdc++/90050] std::filesystem::path segfault in destructor

2019-04-12 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050

--- Comment #1 from Mihai Preda  ---
I would hope somebody would take a look and reject this issues as invalid for
some reason, because otherwise it's rather severe.

[Bug libstdc++/90050] New: std::filesystem::path segfault in destructor

2019-04-11 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050

Bug ID: 90050
   Summary: std::filesystem::path segfault in destructor
   Product: gcc
   Version: 8.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mpreda at gmail dot com
  Target Milestone: ---

#include 

int main() {
  std::filesystem::path p = "foo";
}

g++ -g --std=c++17 path.cpp

./a.out 
Segmentation fault (core dumped)

g++ --version
g++ (Ubuntu 8.3.0-6ubuntu1) 8.3.0

uname -a
Linux x2 5.0.6-050006-generic #201904030534 SMP Wed Apr 3 05:36:14 UTC 2019
x86_64 x86_64 x86_64 GNU/Linux

Ubuntu 19.04.

Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x55c2ac25149b in std::vector >::~vector (this=0x23,
__in_chrg=) at /usr/include/c++/8/bits/stl_vector.h:567
567 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
(gdb) bt
#0  0x55c2ac25149b in std::vector >::~vector (this=0x23,
__in_chrg=) at /usr/include/c++/8/bits/stl_vector.h:567
#1  0x55c2ac251314 in std::filesystem::__cxx11::path::~path (this=0x3,
__in_chrg=) at /usr/include/c++/8/bits/fs_path.h:208
#2  0x55c2ac251f5c in std::filesystem::__cxx11::path::_Cmpt::~_Cmpt
(this=0x3, __in_chrg=) at /usr/include/c++/8/bits/fs_path.h:643
#3  0x55c2ac251f77 in std::_Destroy
(__pointer=0x3) at /usr/include/c++/8/bits/stl_construct.h:98
#4  0x55c2ac251e27 in
std::_Destroy_aux::__destroy
(__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:108
#5  0x55c2ac251a98 in std::_Destroy
(__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:137
#6  0x55c2ac2517a9 in std::_Destroy (__first=0x3, __last=0x0) at
/usr/include/c++/8/bits/stl_construct.h:206
#7  0x55c2ac2514b1 in std::vector >::~vector
(this=0x7ffe3ad201d0, __in_chrg=)
at /usr/include/c++/8/bits/stl_vector.h:567
#8  0x55c2ac251314 in std::filesystem::__cxx11::path::~path
(this=0x7ffe3ad201b0, __in_chrg=) at
/usr/include/c++/8/bits/fs_path.h:208
#9  0x55c2ac251230 in main () at path.cpp:4

[Bug c++/87121] wrong 128-bit integer multiplication with mixed bit size

2018-08-27 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87121

--- Comment #2 from Mihai Preda  ---
OK my bad.

I don't understand exactly why the  or the std:: pow() version is
preferred, but this seems to be what's happening, and explains the behavior.

Feel free to close this.

[Bug c++/87121] New: wrong 128-bit integer multiplication with mixed bit size

2018-08-27 Thread mpreda at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87121

Bug ID: 87121
   Summary: wrong 128-bit integer multiplication with mixed bit
size
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mpreda at gmail dot com
  Target Milestone: ---

Created attachment 44613
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44613&action=edit
repro source

Ubuntu 18.04.1
Linux x2 4.15.0-32-generic #35-Ubuntu SMP Fri Aug 10 17:58:07 UTC 2018 x86_64
x86_64 x86_64 GNU/Linux

On g++7 and g++8:

g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0

g++-8 (Ubuntu 8-20180414-1ubuntu2) 8.0.1 20180414 (experimental) [trunk
revision 259383]

In some special context which seems to include as relevant:
- an include of 
- using namespace std;

the integer multiplication 128-bit times 64-bit produces incorrect result.
See attached small repro case.

Expected output (see attached source): all 1.
Observed output:
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

[Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2

2012-12-03 Thread mpreda at gmail dot com


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



--- Comment #7 from Mihai Preda  2012-12-03 22:13:03 
UTC ---

Thanks, I didn't realize that (unsigned)-1.0 is undefined.



For the behavior I was expecting it's enough to use an intermediary cast

through int, e.g. (unsigned)(int)-1.0.



It may be nice to generate a consistent (-O0/-O1) result for (unsigned)-1.0

though, even if not required by the standard.


[Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2

2012-12-01 Thread mpreda at gmail dot com


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



 Bug #: 9

   Summary: Marshalling double through union with inlines,

incorrect behavior with -O2

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: major

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: mpr...@gmail.com





Created attachment 28848

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28848

.ii preprocessed source



The following simple program returns different results depending on being

compiled with / without -O2.



The expected result is (unsigned)-1, but the observed result with -O2 is 0.



//--

union V {

long long v;

double dbl;

};



inline long long VAL_NUM(double d)   { return V{dbl: d}.v; }

inline double GET_NUM(long long val) { return V{v: val}.dbl; }



int main() {

return (unsigned) GET_NUM(VAL_NUM(-1));

}

//-



gcc -v -save-temps -std=c++11 -Wall bug.cpp

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs

--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr

--program-suffix=-4.7 --enable-shared --enable-linker-build-id

--with-system-zlib --libexecdir=/usr/lib --without-included-gettext

--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7

--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu

--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object

--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686

--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu

--host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-mtune=generic'

'-march=x86-64'

 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -E -quiet -v -imultiarch

x86_64-linux-gnu -D_GNU_SOURCE bug.cpp -mtune=generic -march=x86-64 -std=c++11

-Wall -fpch-preprocess -fstack-protector -o bug.ii

ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"

ignoring nonexistent directory

"/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/include/c++/4.7

 /usr/include/c++/4.7/x86_64-linux-gnu

 /usr/include/c++/4.7/backward

 /usr/lib/gcc/x86_64-linux-gnu/4.7/include

 /usr/local/include

 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed

 /usr/include/x86_64-linux-gnu

 /usr/include

End of search list.

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-mtune=generic'

'-march=x86-64'

 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -fpreprocessed bug.ii -quiet

-dumpbase bug.cpp -mtune=generic -march=x86-64 -auxbase bug -Wall -std=c++11

-version -fstack-protector -o bug.s

GNU C++ (Ubuntu/Linaro 4.7.2-2ubuntu1) version 4.7.2 (x86_64-linux-gnu)

compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,

MPC version 0.9

warning: GMP header version 5.0.2 differs from library version 5.0.5.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

GNU C++ (Ubuntu/Linaro 4.7.2-2ubuntu1) version 4.7.2 (x86_64-linux-gnu)

compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,

MPC version 0.9

warning: GMP header version 5.0.2 differs from library version 5.0.5.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: 521527ea42f0901bf839bcaad0cb13e6

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-mtune=generic'

'-march=x86-64'

 as -v --64 -o bug.o bug.s

GNU assembler version 2.22.90 (x86_64-linux-gnu) using BFD version (GNU

Binutils for Ubuntu) 2.22.90.20120924

COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/

LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-mtune=generic'

'-march=x86-64'

 /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2 --sysroot=/ --build-id

--no-add-needed --as-needed --eh-frame-hdr -m elf_x86_64 --hash-style=gnu

-dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.