dash icon indicating copy to clipboard operation
dash copied to clipboard

cpp17/polymorphic_allocator.h is not standard complient

Open bertwesarg opened this issue 5 years ago • 7 comments

This file containes __attribute__((aligned()) statements, which are not standard complient.

Please fix.

bertwesarg avatar Aug 27 '19 08:08 bertwesarg

any news here? thanks.

bertwesarg avatar Sep 04 '19 06:09 bertwesarg

very unlucky, to get no reply here. Any one can at least give me a work around?

bertwesarg avatar Dec 16 '19 14:12 bertwesarg

Yes, it appears that most people around have gone dormant. I just did a quick google on this issue. It appears there is no portable standard C++ way of specifying the alignment of a type. Can you provide details of why this is a problem and how it manifests?

devreal avatar Dec 16 '19 14:12 devreal

The compiler refuses to compile ;-)

bertwesarg avatar Dec 16 '19 14:12 bertwesarg

I'm now using this:

@@ -141,16 +141,16 @@ struct aligned_chunk<8> {
   long long x;
 };
 template <>
-struct aligned_chunk<16> {
-  __attribute__((aligned(16))) char x;
+struct alignas(16) aligned_chunk<16> {
+  char x;
 };
 template <>
-struct aligned_chunk<32> {
-  __attribute__((aligned(32))) char x;
+struct alignas(32) aligned_chunk<32> {
+  char x;
 };
 template <>
-struct aligned_chunk<64> {
-  __attribute__((aligned(64))) char x;
+struct alignas(64) aligned_chunk<64> {
+  char x;
 };
 
 // Adaptor to make a polymorphic allocator resource type from an STL allocator

It is described here: https://en.cppreference.com/w/cpp/language/alignas

bertwesarg avatar Dec 16 '19 14:12 bertwesarg

Can you post a PR for this?

devreal avatar Dec 16 '19 14:12 devreal

That looks good. Please post a PR.

rkowalewski avatar Dec 16 '19 15:12 rkowalewski