Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

aligned_alloc is not available despite C++17 flag



  • Hi all. I'm building on a Mac with an attempt to specify C++17 in my Qt 5.12 project file as follows:

    CONFIG += c++17

    also added:
    QMAKE_CXXFLAGS += -std=c++17

    A clang version inquiry returns:
    Apple LLVM version 10.0.0 (clang-1000.11.45.5)

    In a C++ source file in an object method, I'm trying to do an aligned_alloc. But regardless of including stdlib.h or cstdlib, this is not a recognized function, with or without "std::".

    Anybody have an insight on this? Thanks!



  • Have you verified that other c++17 features are available when including the flags?
    First, see if the problem is specific to your Qt project, or if it is a problem with any c++17 compilation on your MAC platform.

    I'd also look to see if you have multiple c++ compilers on your machine, and maybe the default Qt proejct build is using one other than you think.

    I'm also curious why even need aligned_alloc, as any compiler I've ever used will automatically set allocation on the native word size boundary. In the old days this was often necessary to avoid odd-address violations, but in modern architectures you sometimes still pay a performance penalty when aligning data at odd addresses.



  • @Kent-Dorfman Thanks for your answer.

    I'm using a third-party library that wants buffers at certain alignments. I don't know what the compiler will do, so I thought it'd be best to make sure. Also, some video encoders want buffers aligned to specific multiples.

    Indeed it looks like this is a system-wide problem. I created an Xcode C++ project and set the language target at C++17 (sort of; see screen shots). Again, align_alloc was missing.

    Here are the available compilers listed in Xcode, and what Qt is using. It's odd that C++ 17 language dialect is listed, but LLVM only says "C++ 11 support."

    0_1551405537980_compilers.png


  • Lifetime Qt Champion



  • @jsulm Thanks. I had tried that. It's an Apple problem. Confirmed defect: My report has already been tagged as a dupe.


  • Lifetime Qt Champion

    Hi,

    What report would that be ?



  • @SGaist The Apple bug report that was flagged as a dupe of Radar 19226311. Curiously, that one is categorized as closed; but clearly the problem isn't fixed. I can't see any more details than that.

    I encourage other Apple developers to file bug reports on this issue, in case it's being blown off.


  • Lifetime Qt Champion

    @Stokestack Can you post a link to that closed bug ticket?



  • @jsulm No. All I have is the number. It's not publicly accessible.


Log in to reply