[Bug c++/56868] New: Constexpr example in 7.1.5/5 fails to compile correctly

2013-04-07 Thread g++bug at oxyware dot com


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



 Bug #: 56868

   Summary: Constexpr example in 7.1.5/5 fails to compile

correctly

Classification: Unclassified

   Product: gcc

   Version: 4.7.0

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

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

ReportedBy: g++...@oxyware.com





// The following example from 7.1.5/5 fails the static assert for g3(0)



constexpr int f(void *) { return 0; }

constexpr int f(...) { return 1; }

constexpr int g1() { return f(0); }

constexpr int g2(int n) { return f(n); }

constexpr int g3(int n) { return f(n*0); }



int main()

{

static_assert(g1() == 0, "g1 failed");

static_assert(g2(0) == 1, "g2 failed");

static_assert(g3(0) == 1, "g3 failed");  // fails, g3(0) returns 0 not 1

}


[Bug c++/56868] Constexpr example in 7.1.5/5 fails to compile correctly

2013-04-07 Thread g++bug at oxyware dot com


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



--- Comment #1 from Hubert Matthews  2013-04-07 
18:39:04 UTC ---

Compiled with g++-4.7.0 -Wall -Wextra -std=c++11 on Fedora 14, 64-bit.


[Bug c++/53560] New: Internal compiler error with += and void function (invalid source)

2012-06-01 Thread g++bug at oxyware dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53560

 Bug #: 53560
   Summary: Internal compiler error with += and void function
(invalid source)
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: g++...@oxyware.com


void f() {}

int main()
{
   int i = 0;
   i += f();
}

This is an invalid C++ program but it causes an internal compiler error (see
below).

g++ -v -save-temps -c  gives:

Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
Target: x86_64-unknown-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.7.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -E -quiet -v
-D_GNU_SOURCE argc.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o argc.ii
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include
 /usr/local/include
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -fpreprocessed
argc.ii -quiet -dumpbase argc.cpp -mtune=generic -march=x86-64 -auxbase argc
-version -o argc.s
GNU C++ (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.1, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.1, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 635960e7261d0cad01689b56d992ea9a
argc.cpp: In function ‘int main()’:
argc.cpp:6:11: internal compiler error: in build_target_expr_with_type, at
cp/tree.c:587
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug c++/70444] New: Optimizer removes expression template

2016-03-29 Thread g++bug at oxyware dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70444

Bug ID: 70444
   Summary: Optimizer removes expression template
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: g++bug at oxyware dot com
  Target Milestone: ---

The code below crashes with a SIGSEGV when compiled with g++ 5.3.1 and
optimization turned on.  Gdb shows that the variable v4 has been optimized out
and is a null pointer.  The code runs correctly with no optimization, -O, -Os
or -O1, but crashes with -O2 or -O3.

The bug appears to be present in previous versions of g++ back to 4.7.0 (the
earliest I can test as the code uses C++11).

The code runs correctly with clang++, with or without optimisation.

Correct functionality
$ g++ -std=c++11 % && ./a.out
$ echo $?
33

Incorrect
$ g++ -std=c++11 -O2 % && ./a.out
Segmentation fault (core dumped)

Correct
$ clang++ -std=c++11 -O3 exprtmpl.cpp && ./a.out
$ echo $?
33

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/lto-wrapper
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-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--disable-libgcj --with-default-libstdcxx-abi=gcc4-compatible --with-isl
--enable-libmpx --enable-gnu-indirect-function --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC)

$ clang++ -v
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/5.3.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64


(Platform is 64-bit Fedora 22 on x86_64, using the distribution's version of
g++)


//-
#include 

template 
struct Expression {
Expression(const Left & l, const Right & r) : left(l), right(r) {}
float operator[](unsigned int index) const {
return Op::apply(left[index], right[index]);
}
const Left & left;
const Right & right;
};

struct plus {
static float apply(float l, float r) { return l + r; }
};

template 
Expression operator+(const Left & l, const Right & r)
{
return Expression(l, r);
}

int main()
{
std::vector v1{2, 3.4, 5};
std::vector v2{3, 5.0, 4};
std::vector v3{4, 6.0, 1};
auto v4 = v1 + v2 + v3;
float total = 0;
for (auto i = 0u; i != v1.size(); ++i)
total += v4[i];
return total;
}
//-

[Bug c++/70444] Optimizer removes expression template

2016-03-30 Thread g++bug at oxyware dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70444

--- Comment #4 from Hubert Matthews  ---
Doh, mea culpa.  My apologies.

[Bug c++/79031] New: [C++17] ICE with class template deduction for std::vector and std::initializer_list

2017-01-09 Thread g++bug at oxyware dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79031

Bug ID: 79031
   Summary: [C++17] ICE with class template deduction for
std::vector and std::initializer_list
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: g++bug at oxyware dot com
  Target Milestone: ---

#include 

int main()
{
  std::vector v({4});
}

//g++ 7.0.0 20170108 (experimental) 

Compilation with g++ version "7.0.0 20170108 (experimental)" and -std=c++1z
fails with:

: In function 'std::vector(std::initializer_list<_Tp>, const
allocator_type&)-> std::vector<_Tp, _Alloc> [with _Tp = int; _Alloc =
std::allocator; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator]':
:5:20: internal compiler error: in tsubst_copy, at cp/pt.c:14953
std::vector v({4});
^
mmap: Cannot allocate memory
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Compiler exited with result code 1

This compiles successfully with std::vector v({4}); but not when
attempting to deduce the initializer_list type.

Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78894