Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp17/polymorphic_allocator.h is not standard complient #665

Open
bertwesarg opened this issue Aug 27, 2019 · 7 comments · May be fixed by #676
Open

cpp17/polymorphic_allocator.h is not standard complient #665

bertwesarg opened this issue Aug 27, 2019 · 7 comments · May be fixed by #676
Assignees

Comments

@bertwesarg
Copy link
Member

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

Please fix.

@bertwesarg
Copy link
Member Author

any news here? thanks.

@bertwesarg
Copy link
Member Author

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

@devreal
Copy link
Member

devreal commented Dec 16, 2019

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?

@bertwesarg
Copy link
Member Author

The compiler refuses to compile ;-)

@bertwesarg
Copy link
Member Author

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

@devreal
Copy link
Member

devreal commented Dec 16, 2019

Can you post a PR for this?

@rkowalewski
Copy link

That looks good. Please post a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants