[Bug tree-optimization/82703] Wrong addition of std::array components with -O2 -ftree-loop-vectorize -ftree-slp-vectorize (works fine with -O2)

2017-10-24 Thread frederic.bron at m4x dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82703

--- Comment #2 from Frédéric Bron  ---
Created attachment 42465
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42465=edit
save-temps for g++ 7.2.0

[Bug tree-optimization/82703] Wrong addition of std::array components with -O2 -ftree-loop-vectorize -ftree-slp-vectorize (works fine with -O2)

2017-10-24 Thread frederic.bron at m4x dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82703

--- Comment #1 from Frédéric Bron  ---
Created attachment 42464
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42464=edit
save-temps for g++ 7.2.1

[Bug tree-optimization/82703] New: Wrong addition of std::array components with -O2 -ftree-loop-vectorize -ftree-slp-vectorize (works fine with -O2)

2017-10-24 Thread frederic.bron at m4x dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82703

Bug ID: 82703
   Summary: Wrong addition of std::array components with -O2
-ftree-loop-vectorize -ftree-slp-vectorize (works fine
with -O2)
   Product: gcc
   Version: 7.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: frederic.bron at m4x dot org
  Target Milestone: ---

Created attachment 42463
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42463=edit
Minimal example to reproduce the bug

The small program attached to this message should always pass, i.e. not print
any error. This is the case with -O2. This is also the case with clang++ 4.0.1
with -O3.

However with g++ and "-O2 -ftree-loop-vectorize -ftree-slp-vectorize", v3[1] is
2.0 instead of 4.0.

Note that if I change double to int, long, long long, float or long double, I
have no error.
Also if I do not construct Array from int[3] but from double[3], it works and
if I remove a useless line, it works...

Tested on linux Fedora 26 x86_64 with g++ 7.2.0 and 7.2.1 on westmere,
broadwell, skylake.

To reproduce failure:
g++ -O2 -g -std=c++14 bug.cpp -ftree-loop-vectorize -ftree-slp-vectorize &&
./a.out

g++ 7.2.0 that shows the bug:
Using built-in specs.
COLLECT_GCC=g++-7.2.0
COLLECT_LTO_WRAPPER=/softs/gcc-7.2.0/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /softs/build/gcc-7.2.0/configure --prefix=/softs/gcc-7.2.0
--program-suffix=-7.2.0 --with-gmp-include=/softs/gmp-6.1.2/include
--with-gmp-lib=/softs/gmp-6.1.2/lib
--with-mpfr-include=/softs/mpfr-3.1.5/include
--with-mpfr-lib=/softs/mpfr-3.1.5/lib
--with-mpc-include=/softs/mpc-1.0.3/include --with-mpc-lib=/softs/mpc-1.0.3/lib
--with-isl-include=/softs/isl-0.16.1/include
--with-isl-lib=/softs/isl-0.16.1/lib --disable-isl-version-check --enable-lto
--enable-nls --disable-multilib
Thread model: posix
gcc version 7.2.0 (GCC) 


g++ 7.2.1 that shows the bug:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)

[Bug c++/49812] New: strange return type for built-in operator++(int, int)

2011-07-22 Thread frederic.bron at m4x dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49812

   Summary: strange return type for built-in operator++(int, int)
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: frederic.b...@m4x.org


The following code attempts to detect if operator++ returns void or not.
The program writes true (meaning that operator++ returns void) instead of
false.
msvc 10 and icpc 12.0 are right in writing false.

The standard states in 13.6/3 (Built-in operators):
For every pair (T, VQ), where T is an arithmetic type, and VQ is
either volatile
or empty, there exist candidate operator functions of the form
VQ T operator++(VQ T);
T operator++(VQ T, int);

That means that for an int volatile variable the corresponding built-in
operator should be:
int operator++(int volatile , int);
which should bind well with operator,(const int, returns_void_t).

#include iostream
#include iomanip

namespace detail {
  typedef char yes_type;
  struct no_type { char padding[8]; };

  struct returns_void_t {};
  static yes_type returns_void(returns_void_t);
  static no_type returns_void(int);
}
template typename T int operator,(const T, ::detail::returns_void_t);
template typename T int operator,(const volatile T,
::detail::returns_void_t);

#define RETURNS_VOID(Expr)\
  sizeof(::detail::yes_type)\
  ==\
  sizeof(::detail::returns_void(((Expr), ::detail::returns_void_t(

int main() {
  int volatile one_int_volatile;
  std::coutstd::boolalphaRETURNS_VOID:
(RETURNS_VOID((one_int_volatile++)))'\n';
  return 0;
}


[Bug c++/49812] strange return type for built-in operator++(int, int)

2011-07-22 Thread frederic.bron at m4x dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49812

--- Comment #1 from Frédéric Bron frederic.bron at m4x dot org 2011-07-22 
08:58:31 UTC ---
Created attachment 24809
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=24809
program that fails

This program should write false but writes true.


[Bug c++/49462] New: comparison of const bool and pointer does not yield an error

2011-06-17 Thread frederic.bron at m4x dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49462

   Summary: comparison of const bool and pointer does not yield an
error
   Product: gcc
   Version: 4.5.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: frederic.b...@m4x.org


The following code should produce the error ISO C++ forbids comparison between
pointer and integer when compiled with g++ -std=c++98 -pedantic-errors.
When the bool is not const or volatile of const volatile, the error is
produced. Only when bool is only const, the error is not produced.
Same problem with all comparison operators ==, !=, , =, , =.

int * pi=0;
bool const b=0;
pi==b;
b==pi;