aryanc403's blog

By aryanc403, history, 16 months ago, In English
#pragma GCC target ("sse4")
#include <bits/stdc++.h>

int main(void) {
    std::set<int> s;
    return 0;
}

It fails to compile with error
In file included from /usr/include/c++/13.1.1/string:43, from /usr/include/c++/13.1.1/bitset:52, from /usr/include/c++/13.1.1/x86_64-pc-linux-gnu/bits/stdc++.h:52, from a.cpp:2: /usr/include/c++/13.1.1/bits/allocator.h: In destructor ‘std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_Rb_tree_impl<std::less<int>, true>::~_Rb_tree_impl()’: /usr/include/c++/13.1.1/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<int>]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13.1.1/map:62, from /usr/include/c++/13.1.1/x86_64-pc-linux-gnu/bits/stdc++.h:152: /usr/include/c++/13.1.1/bits/stl_tree.h:662:16: note: called from here 662 | struct _Rb_tree_impl

Compilation command — time g++ -static -DONLINE_JUDGE -O2 -std=c++20 $$${file} -o $$${file}.exe

G++/GCC version g++ (GCC) 13.1.1 20230429 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When, where and how to report it?

Update: GCC Bugzilla

  • Vote: I like it
  • +26
  • Vote: I do not like it

»
16 months ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

Presumably at GCC bug reporting.

As a workaround, you can perhaps use

#include <set>

void __attribute__((target("sse4"))) solve() {
    std::set<int> s;
}

int main() {
    solve();
    return 0;
}

BTW by trying the equivalent with Clang I got a more useful error error: always_inline function '~allocator' requires target feature 'crc32', but would be inlined into function '~_Rb_tree_impl' that is compiled without support for 'crc32', so that seems to be the problem.

(-msse4 on command line also works, but that doesn't work if you're sending the code)

»
16 months ago, # |
  Vote: I like it +17 Vote: I do not like it

Good luck getting GCC people to fix it, though. I reported this bug last year, and it isn't fixed yet.