Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::align not supported by g++4.9

While learning about alignment issues etc, I realized that my implementation of g++4.9 (macports OS X) does not have support for std::align. If I try to compile (with -std=c++11) this example code from http://www.cplusplus.com/reference/memory/align/

// align example
#include <iostream>
#include <memory>

int main() {
  char buffer[] = "------------------------";
  void * pt = buffer;
  std::size_t space = sizeof(buffer) - 1;
  while ( std::align(alignof(int), sizeof(char), pt, space) ) {
    char* temp = static_cast<char*>(pt);
    *temp = '*'; ++temp; space -= sizeof(char);
    pt = temp;
  }
  std::cout << buffer << '\n';
  return 0;
}

the compiler spits out the error

error: 'align' is not a member of 'std'

This seems strange as g++ seems to have implemented alignment support since g++4.8, https://gcc.gnu.org/projects/cxx0x.html (N2341)

The code compiles under clang++ without any problems.

Is this a well known issue of g++ that I am not aware of? The online compilers that I tested (ideone and coliru) reject the code also.

like image 366
vsoftco Avatar asked Nov 21 '14 15:11

vsoftco


1 Answers

Yes, this is a known missing feature for gcc :

  • Bug 53814 : std::align missing
like image 105
quantdev Avatar answered Oct 02 '22 18:10

quantdev