[Bug c++/46626] [4.6 Regression] simple use of virtual methods causes pure virtual method call in c++0x mode

2010-12-24 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46626

--- Comment #8 from Roman Kononov  2010-12-25 
01:49:05 UTC ---
With the patch applied to r168236:

$ cat test.cpp 
struct X {
virtual int& x(int&)=0;
virtual ~X() {}
};

struct Y {
virtual int& y(int&)=0;
virtual ~Y() {}
};

struct Z: X, Y {
int& x(int&);
int& y(int&);
};

void func() {
Z z;
}

$ g++ -c -std=c++0x test.cpp
test.cpp: In function 'void func()':
test.cpp:17:7:   in constexpr expansion of 'z.Z::Z()'
test.cpp:17:7: internal compiler error: in cxx_eval_bare_aggregate, at
cp/semantics.c:6352
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

Without the patch, with the same test.cpp:

$ g++ -c -std=c++0x test.cpp; echo $?
0

Without the patch, with slightly different test1.cpp:

0 r...@wata:~/tmp/qqq>cat test1.cpp 
struct X {
virtual int& x(int&)=0;
//  virtual ~X() {}
};

struct Y {
virtual int& y(int&)=0;
//  virtual ~Y() {}
};

struct Z: X, Y {
int& x(int&);
int& y(int&);
};

void func() {
Z z;
}

0 r...@wata:~/tmp/qqq>g++ -c -std=c++0x test1.cpp
test1.cpp: In function 'void func()':
test1.cpp:17:7:   in constexpr expansion of 'z.Z::Z()'
test1.cpp:17:7: internal compiler error: in cxx_eval_bare_aggregate, at
cp/semantics.c:6338
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug c++/47067] New: [c++0x] ICE in cxx_eval_bare_aggregate, at cp/semantics.c:6352

2010-12-27 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47067

   Summary: [c++0x] ICE in cxx_eval_bare_aggregate, at
cp/semantics.c:6352
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
struct X {
virtual void x();
virtual ~X();
};

struct Y {
virtual void y();
virtual ~Y();
};

struct Z: X, Y {} z;

$ g++ test.cpp -c -std=c++0x
test.cpp:11:19:   in constexpr expansion of 'z.Z::Z()'
test.cpp:11:19: internal compiler error: in cxx_eval_bare_aggregate, at
cp/semantics.c:6352
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

$ svn info | egrep Revision
Revision: 168275

In http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46626#c10, Jakub Jelinek said:

> I see the ICE with the second testcase from #c8 back till r166167.


[Bug tree-optimization/47355] New: [4.6 Regression] ICE: verify_ssa failed with -O2 -fipa-cp-clone

2011-01-18 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47355

   Summary: [4.6 Regression] ICE: verify_ssa failed with -O2
-fipa-cp-clone
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


Created attachment 23025
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23025
"reduced" test case

$ g++ -c -std=c++0x -O2 -fipa-cp-clone test.cpp 
test.cpp: In function 'vector function()':
test.cpp:200:15: error: definition in block 29 does not dominate use in block
28
test.cpp:200:15: error: no immediate_use list
for SSA_NAME: D.2314_94 in statement:
# .MEM_135 = VDEF <.MEM_109>
zfree (D.2314_94);
test.cpp:200:15: internal compiler error: verify_ssa failed
...


[Bug tree-optimization/47355] [4.6 Regression] ICE: verify_ssa failed with -O2 -fipa-cp-clone

2011-01-18 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47355

--- Comment #1 from Roman Kononov  2011-01-19 
01:45:20 UTC ---
Created attachment 23026
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23026
this is the real test case; ignore the other one please


[Bug c++/50707] New: [C++0x] Non-static const data member initializer breaks default constructor

2011-10-12 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50707

 Bug #: 50707
   Summary: [C++0x] Non-static const data member initializer
breaks default constructor
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
int g;

struct S {
   int const v=g;
};

S s;

$ g++ -std=c++0x -c ./test.cpp 
./test.cpp:7:3: error: use of deleted function ‘S::S()’
./test.cpp:3:8: error: ‘S::S()’ is implicitly deleted because the default
definition would be ill-formed:
./test.cpp:3:8: error: uninitialized non-static const member ‘const int S::v’


[Bug middle-end/53161] [4.8 Regression] ICE with weakref function and a function which takes vector types

2012-05-21 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53161

Roman Kononov  changed:

   What|Removed |Added

 CC||roman at binarylife dot net

--- Comment #8 from Roman Kononov  2012-05-21 
21:00:42 UTC ---
Another test case (without vectors):

$ cat test.cpp 
void gg();
static __typeof(gg) __gthrw_gg __attribute__((__weakref__("gg")));

template
struct data {
  template
  data(Y& y,R(X::*f)(A...));
};

template
data make_data(Y& y,R(X::*f)(A...)) {
  return data(y,f);
}

void global(data);

struct test {
  void bar() {}
  void doit() { global(make_data(*this,&test::bar)); }
};

$ g++ -std=c++11 -c test.cpp 
test.cpp:20:2: internal compiler error: vector VEC(ipa_ref_ptr,base) index
domain error, in ipa_remove_reference at ipa-ref.c:84
 };
  ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


[Bug middle-end/53432] [4.8 Regression] ICE failed to reclaim unneeded function in same comdat group

2012-05-22 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53432

Roman Kononov  changed:

   What|Removed |Added

 CC||roman at binarylife dot net

--- Comment #2 from Roman Kononov  2012-05-22 
16:11:42 UTC ---
Here is a testcase (independent of the original one):

$ cat test.cpp
struct A;
struct B;

struct AA { virtual void afoo(A&); };
struct BB { virtual void bfoo(B&); };

template
void bar(A& a,X& x) {
  x.afoo(a);
}

void bar(A& ss,int& x);

struct ZZ: BB, AA {
  int i;
  void afoo(A& a) { bar(a,i); }
  void bfoo(B&);
};

void bar(A& a) {
  ZZ zz;
  bar(a,zz);
}

$ g++ -c -O2 test.cpp 
_ZN2ZZ4afooER1A/0 (virtual void ZZ::afoo(A&)) @0x7f1ecda1cc30
  Type: function
  Visibility: public weak comdat comdat_group:_ZN2ZZ4afooER1A one_only
section_name:.text._ZN2ZZ4afooER1A virtual
  Same comdat group as: _ZThn8_N2ZZ4afooER1A/2
  Address is taken.
  References: 
  Referring: _ZTV2ZZ/16 (addr)
  Availability: not_available
  Function flags: body finalized
  Called by: 
  Calls: 
test.cpp:23:1: internal compiler error: failed to reclaim unneeded function in
same comdat group
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


[Bug middle-end/53432] [4.8 Regression] ICE failed to reclaim unneeded function in same comdat group

2012-05-23 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53432

--- Comment #3 from Roman Kononov  2012-05-23 
14:58:28 UTC ---
It broke in r187631

http://gcc.gnu.org/ml/gcc-cvs/2012-05/msg00628.html


[Bug libstdc++/52309] New: [c++0x] unordered_set illegally requires value_type::operator!=

2012-02-19 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52309

 Bug #: 52309
   Summary: [c++0x] unordered_set illegally requires
value_type::operator!=
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
#include 
struct value {};
struct hash { std::size_t operator()(value const&)const; };
bool operator==(value const&,value const&);
std::unordered_set set;
bool z=(set==set);

$ g++ -std=c++0x -c test.cpp 2>&1 | egrep error
./include/c++/4.7.0/bits/hashtable_policy.h:1116:4: error: no match for
‘operator!=’ in ‘__ity.std::__detail::_Node_const_iterator<_Value,
__constant_iterators, __cache>::operator*() !=
__itx.std::__detail::_Node_const_iterator<_Value, __constant_iterators,
__cache>::operator*()’

"set==set" needs operator!=(value,value).

The "value" type is EqualityComparable and looks good for unordered_set.
(17.6.3.1, 23.2.1, 23.2.5/2 and 23.2.5/11) 

All other associative unordered containers do not need
value_type::operator!=(). Only unordered_set requires it.


[Bug target/52555] New: [Regression] ICE unrecognizable insn with -ffast-math and __attribute__((optimize(xx)))

2012-03-10 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52555

 Bug #: 52555
   Summary: [Regression] ICE unrecognizable insn with -ffast-math
and __attribute__((optimize(xx)))
Classification: Unclassified
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
typedef unsigned long value_t;

struct foo {
static float _factor;
value_t _val;

foo()
:  _val(7)
{
_val=__builtin_ceil(_val * _factor);
}
};

struct bar {
void operator()(foo&);
};

void
__attribute__((optimize("O")))
test() {
foo f;
bar b;
b(f);
}

int main() {
test();
}

$ g++ -c -O2 -ffast-math test.cpp
test.cpp: In function ‘void test()’:
test.cpp:24:1: error: unrecognizable insn:
(insn 9 8 10 3 (parallel [
(set (reg:XF 67)
(unspec:XF [
(reg:XF 68)
] UNSPEC_FRNDINT_CEIL))
(clobber (reg:CC 17 flags))
]) test.cpp:10 -1
 (nil))
test.cpp:24:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,

This happens with x86 and x86_64.


[Bug target/52555] [4.6/4.7 Regression] ICE unrecognizable insn with -ffast-math and __attribute__((optimize(xx)))

2012-03-12 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52555

--- Comment #1 from Roman Kononov  2012-03-12 
12:51:20 UTC ---
It broke in r165823.


[Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.

2011-12-03 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

 Bug #: 51406
   Summary: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of
static_cast to rvalue reference to base class.
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
#include 
#include 

struct A { int a; A() : a(1) {} };
struct B { int b; B() : b(2) {} };
struct X : A, B {};

int main() {
X x;
int a=static_cast(x).a;
int b=static_cast(x).b;
std::cout<<"a="<

[Bug libstdc++/51866] New: [c++0x][4.7 Regression] unordered_set compares moved-out values

2012-01-15 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51866

 Bug #: 51866
   Summary: [c++0x][4.7 Regression] unordered_set compares
moved-out values
Classification: Unclassified
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
#include 
#include 
#include 

struct num {
  int value;
  num(int n) : value(n) {}
  num(num const&)= default;
  num& operator=(num const&) = default;
  num(num&& o)   : value(o.value) { o.value=-1; }
  num& operator=(num&& o){ if (this!=&o) { value=o.value; o.value=-1; }
return *this; }
};

struct num_hash {
  size_t operator()(num const& a)const {
if (a.value<0) std::cout<<"hash of moved value"<

[Bug libstdc++/51866] [c++0x][4.7 Regression] unordered_multiset compares moved-out values

2012-01-15 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51866

--- Comment #2 from Roman Kononov  2012-01-16 
01:50:37 UTC ---
it is been bisected...
r183180 is bad
r170936 is good


[Bug c++/60689] New: Bogus error with atomic::exchange

2014-03-27 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689

Bug ID: 60689
   Summary: Bogus error with atomic::exchange
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: roman at binarylife dot net
  Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
 Build: x86_64-unknown-linux-gnu

$ cat test.cc 
#include 

template
struct X { char stuff[N]; };

template
void test() {
  X x;
  std::atomic> a;
  x = a;
  a.exchange(x);
}

int main() {
  test<9>();
  return 0;
}

$ g++ -std=c++11 -O2 -l atomic test.cc 
In file included from test.cc:1:0:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘_Tp
std::atomic<_Tp>::exchange(_Tp, std::memory_order) [with _Tp = X<9>;
std::memory_order = std::memory_order]’:
test.cc:11:3:   required from ‘void test() [with int N = 9]’
test.cc:15:11:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:225:41: error: invalid
conversion from ‘X<9>*’ to ‘long unsigned int’ [-fpermissive]
  __atomic_exchange(&_M_i, &__i, &tmp, _m); 
 ^
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:225:41: error: cannot
convert ‘std::memory_order’ to ‘void*’ for argument ‘4’ to ‘void
__atomic_exchange(long unsigned int, volatile void*, void*, void*, int)’

$ g++ --version
g++ (GCC) 4.9.0 20140327 (experimental)
...

[Bug c++/60695] New: std::atomic doesn't work when X is of zero size

2014-03-28 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60695

Bug ID: 60695
   Summary: std::atomic doesn't work when X is of zero size
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: roman at binarylife dot net

$ cat test.cc 
#include 

struct X {
  char stuff[0];
};

X foo(std::atomic& a, X x) {
  a = x;
  return a;
}

$ g++ -std=c++11 -c test.cc 
In file included from test.cc:1:0:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘void
std::atomic<_Tp>::store(_Tp, std::memory_order) [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:183:18:   required from ‘_Tp
std::atomic<_Tp>::operator=(_Tp) [with _Tp = X]’
test.cc:8:5:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:199:39: error: argument 1 of
‘__atomic_store’ must be a pointer to a nonzero size object
   { __atomic_store(&_M_i, &__i, _m); }
   ^
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘_Tp
std::atomic<_Tp>::load(std::memory_order) const [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:176:21:   required from
‘std::atomic<_Tp>::operator _Tp() const [with _Tp = X]’
test.cc:9:10:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:209:31: error: argument 1 of
‘__atomic_load’ must be a pointer to a nonzero size object
  __atomic_load(&_M_i, &tmp, _m); 
   ^
$ g++ --version
g++ (GCC) 4.9.0 20140327 (experimental)
...

[Bug libstdc++/60695] std::atomic doesn't work when X is of zero size

2014-03-28 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60695

--- Comment #3 from Roman Kononov  ---
Yes, it is definitely silly in some sense. But, some templated user code might
become more complex with this behaviour. If gcc supports zero-sized objects it
would be nice to support them fully. The implementation for this case might do
the synchronization part without any data exchange.


[Bug c++/61541] New: Unexpected error: 'identifier' was not declared in this scope, or ICE in gimplify.c:7871

2014-06-17 Thread roman at binarylife dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61541

Bug ID: 61541
   Summary: Unexpected error: 'identifier' was not declared in
this scope, or ICE in gimplify.c:7871
   Product: gcc
   Version: 4.8.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: roman at binarylife dot net

$ cat test1.cc 
struct foo {
  template 
  struct bar {
char* p = new char[size];
  };
};

foo::bar<10> moo;

$ g++ -std=c++11 -c test1.cc
test1.cc:4:24: error: ‘size’ was not declared in this scope
 char* p = new char[size];
^

$ cat test2.cc 
struct zoo {
  zoo(char*);
};

struct foo {
  template 
  struct bar {
static constexpr int s = size;
zoo p = zoo(new char[s]);
  };
};

foo::bar<10> moo;

$ g++ -std=c++11 -c test2.cc |& head -4
test2.cc: In constructor ‘constexpr foo::bar<10>::bar()’:
test2.cc:9:27: internal compiler error: in gimplify_expr, at gimplify.c:7871
 zoo p = zoo(new char[s]);
   ^

$ g++ --version | head -1
g++ (GCC) 4.8.4 20140617 (prerelease)

GCC 4.9 and later don't show these errors.

[Bug c/43374] ICE with __builtin_isinf() and _Decimal argument

2010-03-18 Thread roman at binarylife dot net


--- Comment #3 from roman at binarylife dot net  2010-03-18 14:52 ---
This looks related.

$ cat test.c
_Decimal64 func() {
  return 9e384dd + 9e384dd;
}

$ gcc -c test.c
test.c: In function 'func':
test.c:2:3: internal compiler error: in decimal_to_decnumber, at dfp.c:115
...


-- 


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



[Bug c++/43622] New: no C++ typeinfo for __float128 and __int128

2010-04-01 Thread roman at binarylife dot net
$ cat tf-test.cpp
#include 
typedef float type __attribute__((__mode__(TF)));
int main() { return *(typeid(type).name()); }

$ g++ tf-test.cpp
/tmp/cc8RAh4o.o: In function `main':
tf-test.cpp:(.text+0x5): undefined reference to `typeinfo for __float128'
collect2: ld returned 1 exit status

$ cat ti-test.cpp
#include 
typedef int type __attribute__((__mode__(TI)));
int main() { return *(typeid(type).name()); }

$ g++ ti-test.cpp
/tmp/ccI1nTTK.o: In function `main':
ti-test.cpp:(.text+0x5): undefined reference to `typeinfo for __int128'
collect2: ld returned 1 exit status

$ g++ --version | head -1
g++ (GCC) 4.5.0 20100401 (experimental)


-- 
   Summary: no C++ typeinfo for __float128 and __int128
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c++/43632] New: -g option became very slow after r157834

2010-04-02 Thread roman at binarylife dot net
$ svn up -r157834 ~/src/gcc
...
$ make -C ~/src/gcc install
...
$ time g++ -std=c++0x -O2 -c test.cpp -g
real4m47.882s
user4m47.226s
sys 0m0.577s
$ time g++ -std=c++0x -O2 -c test.cpp
real0m28.247s
user0m27.935s
sys 0m0.282s

For comparison:

$ svn up -r157833 ~/src/gcc
...
$ make -C ~/src/gcc install
...
$ time g++ -std=c++0x -O2 -c test.cpp -g
real0m38.055s
user0m37.476s
sys 0m0.475s
$ time g++ -std=c++0x -O2 -c test.cpp 
real0m28.149s
user0m27.861s
sys 0m0.278s


-- 
   Summary: -g option became very slow after r157834
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c++/43632] -g option became very slow after r157834

2010-04-02 Thread roman at binarylife dot net


--- Comment #1 from roman at binarylife dot net  2010-04-02 19:42 ---
Created an attachment (id=20293)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20293&action=view)
test.cpp


-- 


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



[Bug c++/43720] New: undefined reference to static const integral template class member

2010-04-11 Thread roman at binarylife dot net
$ cat test1.cpp
template
void zzz(X const& x) {
   return;
}

struct ttt_t {
   static int const static_const_int=0;
   int func()const {
  zzz(static_const_int);
  return 0;
   }
};

int main() {
   return ttt_t().func();
}

$ g++ -O test1.cpp --save-temps
#no errors

$ g++ test1.cpp --save-temps
test1.o: In function `ttt_t::func() const':
test1.cpp:(.text._ZNK5ttt_t4funcEv[ttt_t::func() const]+0xd): undefined
reference to `ttt_t::static_const_int'
collect2: ld returned 1 exit status

$ grep 'static_const_int' test1.s
movl$_ZN5ttt_t16static_const_intE, %edi

$ cat test2.cpp
template
void __attribute((noinline)) zzz(X const& x) {
   static bool volatile junk=false;
   if (junk) zzz(x);
   return;
}

struct ttt_t {
   static int const static_const_int=0;
   int func()const {
  zzz(static_const_int);
  return 0;
   }
};

int main() {
   return ttt_t().func();
}

$ g++ -O3 test2.cpp --save-temps
#no errors

$ g++ -O2 test2.cpp --save-temps
test2.o: In function `main':
test2.cpp:(.text+0x5): undefined reference to `ttt_t::static_const_int'
collect2: ld returned 1 exit status

$ grep 'static_const_int' test2.s
movl$_ZN5ttt_t16static_const_intE, %edi

4.4.4 has same issues except that -O3 fails with test2.cpp


-- 
   Summary: undefined reference to static const integral template
class member
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c++/43720] undefined reference to static const integral class member

2010-04-12 Thread roman at binarylife dot net


--- Comment #3 from roman at binarylife dot net  2010-04-12 12:41 ---
sorry for bothering :)
thanks


-- 


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



[Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong

2010-04-18 Thread roman at binarylife dot net
$ cat test.c
#include 
int main() {
  _Decimal128 const a=1.1dl;
  _Decimal128 const b=1.111e-6158dl;
  _Decimal128 volatile x=a;
  _Decimal128 volatile y=b;
  double ab=a*b*1.0e6000dl;
  double xy=x*y*1.0e6000dl;
  printf("ab=%g\n",ab);
  printf("xy=%g\n",xy);
}

$ gcc test.c && ./a.out
ab=9.64506e-159
xy=9.64506e-159

$ gcc -O test.c && ./a.out
ab=1.23457e-158
xy=9.64506e-159

$ gcc --version | head -1
gcc (GCC) 4.5.1 20100418 (prerelease)

The correct value is 1.23457e-158:

$ echo "1.1*1.111" | bc
1.234567888

A simple modification of test.c can show that it is x*y and a*b, when computed
by libbid, are incorrect. The a*b expression, when computed by gcc (with -O),
is correct.

To further diagnose, I extracted libbid from the gcc source tree and compiled
it outside of gcc to link it with the above test.c program. I added some
#defines to compile the library and renamed some functions to call them
directly from the test.

I found that if compiled with -O only, libbid multiplies correctly. With -O
-ftree-pre, it multiplies incorrectly.

The real job is done by bid128_ext_fma() (about 3000 C lines).


-- 
   Summary: [4.5 regression] -O -ftree-pre options compile libbid
wrong
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug tree-optimization/43783] [4.5 regression] -O -ftree-pre options compile libbid wrong

2010-04-18 Thread roman at binarylife dot net


--- Comment #2 from roman at binarylife dot net  2010-04-18 18:34 ---
(In reply to comment #1)
> This needs a testcase.  The libdecnumber code is a mess (and I can't find
> an implementation for bid128_ext_fma()).
> 

bid128_ext_fma() is in libgcc/config/libbid/bid128_fma.c


-- 


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



[Bug tree-optimization/43783] [4.5 regression] -O -ftree-pre options compile libbid wrong

2010-04-18 Thread roman at binarylife dot net


--- Comment #3 from roman at binarylife dot net  2010-04-19 04:25 ---
Starting from r150519 gcc compiles its own internal libbid wrong.

With the previous revision of gcc, the output of the above test.c is correct:

$ gcc -O test.c && ./a.out
ab=1.23457e-158
xy=1.23457e-158


-- 


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



[Bug tree-optimization/43783] [4.5 Regression] -O -ftree-pre options compile libbid wrong

2010-04-19 Thread roman at binarylife dot net


--- Comment #9 from roman at binarylife dot net  2010-04-19 20:46 ---
The 4.5 branch works for me if patched this way.
Thanks.


-- 


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



[Bug libstdc++/63322] New: std::atomic where T is not trivially copyable should be disabled.

2014-09-21 Thread roman at binarylife dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63322

Bug ID: 63322
   Summary: std::atomic where T is not trivially copyable
should be disabled.
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: roman at binarylife dot net

[atomic.types.generic]: There is a generic class template atomic. The type
of the template argument T shall be trivially copyable (3.9).

It would be helpful if std::atomic disallowed wrong T because the generated
code is obviously makes no sense (at least for x86_64): bar() returns a
hard-coded NaN.

$ cat test.cc 
#include 

long double foo(const long double& f) noexcept;

struct X {
  X() = default;
  X(X const& o) noexcept : f(foo(o.f)) {}
  X& operator=(X const& o) noexcept { f = foo(o.f); return *this; }
  long double f = foo(0);
};

extern std::atomic a;

long double bar() { a.load().f; }

$ g++ -c -O2 --save-temps -std=c++11 test.cc && echo ok
ok

$ cat test.s 
.file   "test.cc"
.section.text.unlikely,"ax",@progbits
.LCOLDB2:
.text
.LHOTB2:
.p2align 4,,15
.globl  _Z3barv
.type   _Z3barv, @function
_Z3barv:
.LFB330:
.cfi_startproc
fldz
subq$24, %rsp
.cfi_def_cfa_offset 32
movq%rsp, %rdi
fstpt   (%rsp)
call_Z3fooRKe
fstp%st(0)
movl$5, %esi
movl$a, %edi
call__atomic_load_16
flds.LC1(%rip)
addq$24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE330:
.size   _Z3barv, .-_Z3barv
.section.text.unlikely
.LCOLDE2:
.text
.LHOTE2:
.section.rodata.cst4,"aM",@progbits,4
.align 4
.LC1:
.long   2143289344
.ident  "GCC: (GNU) 5.0.0 20140920 (experimental)"
.section.note.GNU-stack,"",@progbits


[Bug c++/48707] New: [4.6/4.7 Regression] [c++0x] ICE initializing static const int

2011-04-20 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48707

   Summary: [4.6/4.7 Regression] [c++0x] ICE initializing static
const int
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net
  Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
 Build: x86_64-unknown-linux-gnu


$ cat test.cc 
struct A {
  static int a();
};

template
struct B: A {
  static int const b;
};

template
int const B::b=B::a();

$ g++ -c -std=c++0x test.cc
test.cc:11:27: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug c++/48707] [4.6/4.7 Regression] [c++0x] ICE initializing static const int

2011-04-21 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48707

--- Comment #1 from Roman Kononov  2011-04-21 
15:57:12 UTC ---
It is caused by -r170488.


[Bug c++/45113] New: absent or confusing diagnostics of invalid template argument list in implicit template class instantiation

2010-07-28 Thread roman at binarylife dot net
$cat test1.cpp
template struct is_same { static bool const value=false;
};
template struct is_same { static bool const value=true; };
template struct U {};
struct Q { typedef U C; };
typedef char check[is_same::value ? 1 : -1];

$g++ -std=gnu++0x -c test1.cpp && echo $?
0

In 14.3.1, the Standard says: "A template-argument for a template-parameter
which is a type shall be a type-id." The test must fail compilation, and Q::C
can not be int.

$cat test2.cpp
template struct U {};
typedef U B;

$g++ -std=gnu++0x -c test2.cpp 
test2.cpp:2:25: error: invalid type in declaration before ';' token

This message is confusing.

$cat test3.cpp 
template struct U {};
typedef U A;

$g++ -c test3.cpp 
test3.cpp:2:22: error: wrong number of template arguments (1, should be 2)
test3.cpp:1:40: error: provided for 'template struct U'
test3.cpp:2:25: error: invalid type in declaration before ';' token

These messages are confusing.


-- 
   Summary: absent or confusing diagnostics of invalid template
argument list in implicit template class instantiation
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c++/46688] New: [4.6 Regression] g++ requires a function declaration when it should not

2010-11-27 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46688

   Summary: [4.6 Regression] g++ requires a function declaration
when it should not
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cc 
struct A {
   A(int);
};

struct B {
   B() {}
   A a[];
};
$ g++ test.cc 
test.cc: In constructor 'B::B()':
test.cc:6:8: error: no matching function for call to 'A::A()'
test.cc:2:4: note: candidates are: A::A(int)
test.cc:1:8: note: A::A(const A&)

The same problem with A a[0];

v4.5 is perfect in this respect.


[Bug libstdc++/46718] New: [c++0x] nullptr_t must be scalar

2010-11-29 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46718

   Summary: [c++0x] nullptr_t must be scalar
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
#include 
static_assert(std::is_scalar::value,"not scalar");

$ g++ -c -std=c++0x test.cpp 
test.cpp:2:1: error: static assertion failed: "not scalar"


[Bug libstdc++/46718] [c++0x] nullptr_t must be scalar

2010-11-29 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46718

--- Comment #1 from Roman Kononov  2010-11-30 
02:09:44 UTC ---
This is required by "20.7.4.2 Composite type traits" and "3.9 Types"


[Bug c++/46733] New: [c++0x] member function template is used for copy-construction when it should not

2010-11-30 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46733

   Summary: [c++0x] member function template is used for
copy-construction when it should not
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


Compiling the following invalid program GCC violates 12.8/7 "A member function
template is never instantiated to perform the copy of a class object to an
object of its class type."

$ cat test.cpp 
#include 

struct X {
  X()=default;
  X(X&&)=default;
  template X(Y const&) { abort(); }
};

int main() {
  X a={};
  X b(a);
  return 0;
}

$ g++ -std=c++0x test.cpp && ./a.out 
Aborted


[Bug c++/46736] New: [c++0x] move constructor is not implicitly deleted when it should be

2010-11-30 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46736

   Summary: [c++0x] move constructor is not implicitly deleted
when it should be
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cc 
struct U {
  U();
  U(U const&);
};

struct X {
  U const u;
  X();
  X(X&&);
};

X::X(X&&)=default;

X f() {
  return X();
}

$ g++ -c -std=c++0x test.cc; echo $?
0

If "=default" is inside the class, gcc properly emits an error.

Another one with the same issue:

$ cat test.cc 
#include 
#include 

struct U {
  U() {}
  U(U const&) { abort(); }
};

struct X {
  U const u;
  X() : u() {}
  X(X&&);
};

X::X(X&&)=default;

int main() {
  X a;
  X b=std::move(a);
  return 0;
}

$ g++ -std=c++0x test.cc && ./a.out 
Aborted


[Bug c++/49176] New: [4.6 Regression][c++0x] valid code rejected with "error: uninitialized const"

2011-05-26 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49176

   Summary: [4.6 Regression][c++0x] valid code rejected with
"error: uninitialized const"
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
struct A { static int a(); };

template
struct B { static int const b; };

int f() { return B<0>::b; }

template 
int const B::b=A::a();

$ g++ -c -std=c++0x test.cpp 
test.cpp: In instantiation of ‘const int B<0>::b’:
test.cpp:6:24:   instantiated from here
test.cpp:9:11: error: uninitialized const ‘B<0>::b’ [-fpermissive]


[Bug c++/49176] [4.6 Regression][c++0x] valid code rejected with "error: uninitialized const"

2011-05-26 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49176

--- Comment #2 from Roman Kononov  2011-05-26 
20:15:35 UTC ---
4.6 branch, r174294


[Bug libstdc++/49219] New: [c++0x] comparing unordered containers illegally require key compare

2011-05-28 Thread roman at binarylife dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49219

   Summary: [c++0x] comparing unordered containers illegally
require key compare
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ro...@binarylife.net


$ cat test.cpp 
#include 
#include 
struct K {
//  bool operator!=(K const&)const;
//  bool operator==(K const&)const;
};
struct H { std::size_t operator()(K const&)const; };
struct E { bool operator()(K const&,K const&)const; };
extern std::unordered_set a;
extern std::unordered_map b;
extern std::unordered_multiset c;
extern std::unordered_multimap d;
bool af=(a==a);
bool bf=(b==b);
bool cf=(c==c);
bool df=(d==d);

$ g++ -c -std=c++0x test.cpp
... failure

Each of "bool xf=(x==x);" require "bool K::operator!=(K const&)const" and/or
"bool K::operator==(K const&)const". The provided E type should be used for key
compare.