[Bug c++/80451] New: return implicit type conversion to std::optional does not compile

2017-04-18 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80451

Bug ID: 80451
   Summary: return implicit type conversion to std::optional does
not compile
   Product: gcc
   Version: 6.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: krisk0.2017.02.27 at protonmail dot com
  Target Milestone: ---
  Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
 Build: x86_64-pc-linux-gnu

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

* Short story: 

under certain conditions, `return v;` statement does not compile.

 * the exact version of GCC;

gcc-6.3.0 (Gentoo 6.3.0 p1.0) 6.3.0

 * the system type;

Gentoo on x86_64

 * the options given when GCC was configured/built;

COLLECT_GCC=gcc-6.3.0
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/portage/sys-devel/gcc-6.3.0/work/gcc-6.3.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/6.3.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --disable-nls --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.3.0 p1.0'
--disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point
--enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap
--disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify
--enable-libvtv --disable-libquadmath --enable-lto --without-isl
--enable-libsanitizer --disable-default-pie --disable-default-ssp
Thread model: posix
gcc version 6.3.0 (Gentoo 6.3.0 p1.0) 

 * the complete command line that triggers the bug;

gcc-6.3.0 -xc++ -O2 -std=gnu++14 return-bug.c

 * the compiler output (error messages, warnings, etc.); 

return-bug.cc: In function
'std::experimental::fundamentals_v1::optional
meal(std::__cxx11::string)':
return-bug.cc:39:12: error: could not convert 'b' from 'Bread_and_butter' to
'std::experimental::fundamentals_v1::optional'
 return b;
^

 * the preprocessed file (*.i*) that triggers the bug

see attachment

 * Why the code should compile

 1. According to C++ standard §6.6.3 `The value of the expression is implicitly
converted to the return type of the function in which it appears.`
 2. According to
http://en.cppreference.com/w/cpp/experimental/optional/optional, non-explicit
constructor from T& to std::experimental::optional should exist.
 3. The code compiles under gcc 5.4

[Bug libstdc++/80451] return implicit type conversion to std::experimental::optional does not compile

2017-04-18 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80451

--- Comment #2 from Денис Крыськов  ---
None of official documents I read says that optional invokes
copy-constructor of T.

Jonathan, did you describe a change in specification, or a temporary
walkaround?

[Bug libstdc++/80451] [6/7 Regression] return implicit type conversion to std::experimental::optional does not compile

2017-04-18 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80451

--- Comment #6 from Денис Крыськов  ---
Seems like a serious bug in compiler.

Jonathan, thanks for quick investigation.

[Bug libstdc++/80451] [6/7 Regression] return implicit type conversion to std::experimental::optional does not compile

2017-04-18 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80451

--- Comment #8 from Денис Крыськов  ---
If I understand correctly,
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 is not
implemented in gcc 5.4 and 6.3. Which means some code runs slower than is
should. To be sure that a fast constructor is called, I need to delete slow
constructor. 

Which results in bloated code (each and every class should contain delete
statement).

If that's not serious, that's unpleasant.

[Bug libstdc++/79743] New: std::experimental::optional constructor broken in gcc 6.2

2017-02-28 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79743

Bug ID: 79743
   Summary: std::experimental::optional constructor
broken in gcc 6.2
   Product: gcc
   Version: lto
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: krisk0.2017.02.27 at protonmail dot com
  Target Milestone: ---

Created attachment 40841
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40841&action=edit
all files mentioned in bug-report

Short story: std::experimental::optional copy-constructor is broken
under GCC 6.2. 47-line .cpp proves it.

Long story as required by https://gcc.gnu.org/bugs/:
* the exact version of GCC
 sys-devel/gcc-5.3.0 --- works fine
 sys-devel/gcc-6.2.0 --- buggy
* the system type
 Gentoo on amd64 (Intel Core i5)
* the options given when GCC was configured/built
 See files 5.3.configure and 6.2.configure
* the complete command line that triggers the bug
 Install Google test --- package dev-cpp/gtest;
 g++ -std=c++14 -O2 -lgtest test.cpp && ./a.out
 Test passes under gcc 5.3 and fails under 6.2.
std::experimental::optional constructor sets butter to false though it
should be undefined.
* the compiler output (error messages, warnings)
 None
* the preprocessed file (*.i*)
 test.5.3.ii --- works fine, test passes
 test.6.2.ii --- test fails
```
test.cpp:40: Failure
Value of: !s1.butter
  Actual: false
Expected: true
test.cpp:40: Failure
Value of: Nothing
  Actual: 1-byte object <00>
Expected: s1.butter
Which is: 2-byte object <00-01>
```

[Bug libstdc++/79743] std::experimental::optional constructor broken in gcc 6.2

2017-03-02 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79743

--- Comment #2 from Денис Крыськов  ---
ok, will provided standalone .cpp next time.

Jonathan, thank you.

[Bug c/80345] New: ICE in rewrite_use_nonlinear_expr with -O2

2017-04-06 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80345

Bug ID: 80345
   Summary: ICE in rewrite_use_nonlinear_expr with -O2
   Product: gcc
   Version: 6.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: krisk0.2017.02.27 at protonmail dot com
  Target Milestone: ---

The bug looks like #68021. But #68021 has been fixed Feb 2016 and gcc-6.3 is
dated Dec 2016, so this bug is NOT a duplicate.

 * the exact version of GCC
gcc version 6.3.0 (Gentoo 6.3.0 p1.0)

4.9.3 5.3 5.4 affected, too. clang 3.7.1 compiles fine.

 * the system type 
Gentoo Linux on amd64

 * the options given when GCC was configured/built;
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/6.3.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/portage/sys-devel/gcc-6.3.0/work/gcc-6.3.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/6.3.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/6.3.0/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --disable-nls --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.3.0 p1.0'
--disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point
--enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap
--disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify
--enable-libvtv --disable-libquadmath --enable-lto --without-isl
--enable-libsanitizer --disable-default-pie --disable-default-ssp
Thread model: posix
gcc version 6.3.0 (Gentoo 6.3.0 p1.0) 

 * the complete command line that triggers the bug;

x86_64-pc-linux-gnu-gcc -O2 -pipe -march=native -fPIC
-I/usr/lib64/python2.7/site-packages/sage/ext
-I/usr/lib64/python2.7/site-packages
-I/usr/lib64/python2.7/site-packages/cysignals -I/usr/include/python2.7 -c
flint.c -o
/tmp/portage/dev-python/python-sage-flint-20150625-r0/work/razin-20150625-r0/flint.binding-python2_7/temp.linux-x86_64-2.7/flint.o

 * the compiler output (error messages, warnings, etc.); and
the preprocessed file (*.i*) that triggers the bug
In file included from flint.c:483:0:
C/fmpz_mat/det_suspected_zero.c: In function 'det_divisor_count_y':
C/fmpz_mat/det_suspected_zero.c:180:33: warning: initialization from
incompatible pointer type [-Wincompatible-pointer-types]
   const mp_limb_t** const m_row=m->rows;
 ^
In file included from flint.c:489:0:
C/fmpz_mat/Hadamard_Cramer.c: In function 'hadamard_2arg':
C/fmpz_mat/Hadamard_Cramer.c:127:27: warning: initialization from incompatible
pointer type [-Wincompatible-pointer-types]
   const fmpz** const rows=m->rows;
   ^
In file included from flint.c:492:0:
C/nmod_mat/det_mod_pk.c: In function 'nmod_mat_det_dim4':
C/nmod_mat/det_mod_pk.c:122:32: warning: initialization from incompatible
pointer type [-Wincompatible-pointer-types]
   const mp_limb_t** const rows=M->rows;
^
C/nmod_mat/det_mod_pk.c: In function 'nmod_mat_det_dim4_SE':
C/nmod_mat/det_mod_pk.c:142:32: warning: initialization from incompatible
pointer type [-Wincompatible-pointer-types]
   const mp_limb_t** const rows=M->rows;
^
C/nmod_mat/det_mod_pk.c: In function 'nmod_mat_det_dim3':
C/nmod_mat/det_mod_pk.c:168:32: warning: initialization from incompatible
pointer type [-Wincompatible-pointer-types]
   const mp_limb_t** const rows=A->rows;
^
In file included from flint.c:496:0:
C/nmod_mat/transpose_square_tgt_virgin.c: In function
'nmod_mat_transpose_square_tgt_virgin':
C/nmod_mat/transpose_square_tgt_virgin.c:11:36: warning: initialization from
incompatible pointer type [-Wincompatible-pointer-types]
   const mp_limb_t** const sou_rows=sou->rows;
^
In file included from flint.c:491:0:
C/tmod_mat/invert_square.c: In function 'tmod_mat_invert_transpose':
C/tmod_mat/invert_square.c:226:1: internal compiler error: in
rewrite_use_nonlinear_expr, at tree-ssa-loop-ivopts.c:6448
 tmod_mat_invert_transpose(tmod_mat_t R, const tmod_mat_t S)
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
Se

[Bug tree-optimization/80345] ICE in rewrite_use_nonlinear_expr with -O2

2017-04-06 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80345

--- Comment #2 from Денис Крыськов  ---
Created attachment 41148
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41148&action=edit
the preprocessed file

Ah, sorry, I attached uncompressed file, which was rejected due to big size.

[Bug tree-optimization/80345] [5 Regression] ICE in rewrite_use_nonlinear_expr with -O2

2017-04-07 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80345

--- Comment #7 from Денис Крыськов  ---
Created attachment 41149
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41149&action=edit
gcc5.4 -v stderr/stdout

[Bug tree-optimization/80345] [5 Regression] ICE in rewrite_use_nonlinear_expr with -O2

2017-04-07 Thread krisk0.2017.02.27 at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80345

--- Comment #8 from Денис Крыськов  ---
(In reply to Markus Trippelsdorf from comment #4)
> 6.3 branch works fine.
> Only 5.4.1 is affected. So it looks like a missing backport.

Microarch is Haswell.

I failed to reproduce ICE with gcc 6.3. If this is due to my mistake, I am
sorry. I attached gcc 5.4 stderr/stdout.