[Bug c++/70603] gcc alignas issue with pointers to class

2016-04-09 Thread mhadji at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70603

--- Comment #4 from Marios Hadjieleftheriou  ---
But of course. I am checking the alignment of the wrong things, in my
example...

[Bug c++/70603] gcc alignas issue with pointers to class

2016-04-09 Thread mhadji at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70603

--- Comment #3 from Marios Hadjieleftheriou  ---
I am trying to use posix_memalign and a double pointer to double, and that is
also failing. Is this an overalignment issue as well?

#include 
#include 

struct B { 
B() {
x = new double*[1];
void* p = x[0];
posix_memalign(, 32, 1); 
}   

double** x;
};

struct A
{
A() { b1 = new B(); b2 = new B(); }

B* b1; 
B* b2; 
};

int main(int argc, char** argv) {
A a;

int ret = reinterpret_cast(a.b1->x) % 32 +
reinterpret_cast(a.b2->x) % 32; 

return ret;
}

[Bug c++/36159] C++ compiler should issue a warning with missing new operator

2016-04-09 Thread mhadji at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36159

--- Comment #17 from Marios Hadjieleftheriou  ---
(In reply to Martin Sebor from comment #12)
> Confirmed.  As noted in bug 67911, the solution proposed for the next
> version of C++ is the following:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0035r0.html
> Until it's accepted and implemented, issuing a warning would help users
> avoid the trap.  I happen to be working in this area so I'll see if I can
> come up with something.

The link posted above appears to be broken.

[Bug c++/70603] gcc alignas issue with pointers to class

2016-04-08 Thread mhadji at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70603

--- Comment #1 from Marios Hadjieleftheriou  ---
I just tried using 5.2.0 and I get the same issue.

[Bug c++/70603] New: gcc alignas issue with pointers to template class

2016-04-08 Thread mhadji at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70603

Bug ID: 70603
   Summary: gcc alignas issue with pointers to template class
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mhadji at gmail dot com
  Target Milestone: ---

I am using gcc 4.9.2 and I am trying to properly align statically initialized
arrays for use with AVX. Here is the gist of the code that segfaults due to
alignment issues:

#include 
#include 

struct B {
alignas(32) double x[1] = {0};
};

struct A
{
A() { b1 = new B(); b2 = new B(); }

B* b1;
B* b2;
};

int main(int argc, char** argv) {
A a;

int ret = (ptrdiff_t) a.b1->x % 32 + (ptrdiff_t) a.b2->x % 32;

std::cout << (ptrdiff_t) a.b1->x % 32 << "," << (ptrdiff_t) a.b2->x % 32 <<
"\n";

return ret;
}
On my system array a.b2->x is not aligned on a 32 byte boundary. The size of x
does not matter, as long as it is an array (so "double x = 0" works fine). If I
make the pointers to B statically allocated members instead, it works properly.
If I create local variables *b1 and *b2 inside main, it works properly. If I
use dynamically allocated arrays inside class A and posix_malloc, it works
properly.