Skip to content

std::aligned_alloc not available #80

@Nik-Sch

Description

@Nik-Sch

I am trying to build an existing C++ project with minimal modifications and stumbled across aligned_alloc not being in the std namespace.

This works fine with non-cross-compiler g++ but does not work with x86_64-hermit-g++

#include <cstdlib>
int main() {
  void *x = std::aligned_alloc(0x1000, 0x100);
}
Compile output:
$ x86_64-hermit-g++ -Llib test.cc -std=c++23
test.cc: In function 'int main()':
test.cc:4:18: error: 'aligned_alloc' is not a member of 'std'; did you mean 'aligned_alloc'?
    4 |   void *x = std::aligned_alloc(0x1000, 0x100);
      |                  ^~~~~~~~~~~~~
In file included from /opt/hermit/x86_64-hermit/include/c++/15.1.0/cstdlib:83,
                 from test.cc:1:
/opt/hermit/x86_64-hermit/include/stdlib.h:361:9: note: 'aligned_alloc' declared here
  361 | void *  aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)

Note that it does compile when omitting the std namespace and using the C version.

Do you have any pointers for me where the problem lies?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions