https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121551
Bug ID: 121551 Summary: #include <emmintrin.h> fails with -xc++ -ffreestanding Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- #include <emmintrin.h> -xc++ -ffreestanding (does not reproduce with -xc) Result: /opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/include/mm_malloc.h:34:41: error: 'size_t' has not been declared 34 | extern "C" int posix_memalign (void **, size_t, size_t) throw (); | ^~~~~~ /opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/include/mm_malloc.h:28:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 27 | #include <stdlib.h> +++ |+#include <cstddef> 28 | /opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/include/mm_malloc.h:54:3: error: 'free' was not declared in this scope 54 | free (__ptr); | ^~~~ /opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/include/mm_malloc.h:28:1: note: 'free' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>' 27 | #include <stdlib.h> +++ |+#include <cstdlib> 28 | plus several more complaints about size_t, some of which suggest std::size_t instead. Expected: Gate the mm_malloc.h include on __STDC_HOSTED__, and leave actual intrinsics like _mm_loadu_si128() available. Works in GCC 12, fails (with slightly different errors) in 13, 14 and 15. Likely related to bug 106953. (The unhelpful suggestion to include stdlib.h again is bug 121549.) https://godbolt.org/z/64haeKas3