As of May 2024, the bug has been fixed in GCC 14, but has not been ported to Codeforces yet.
MikeMirzayanov added a new compiler in response to the bug mentioned here. However, it does not come without a catch.
Namely, any pragma that is of the form #pragma GCC target(...)
would
NOT work with this new compiler. The
issue is
well-known by people who use up-to-date compilers but there has not been
much progress towards a fix.
One of the ways to fix it is to add the target pragma AFTER the STL includes. This should make your code compile, but a lot of code would simply not be optimized, so use it at your own risk.
The other way is to use g++-12, but risk a TLE due to the linked post (it’s easy to write hacks for most problems). Fortunately, there is a fix for this hack, but, echoing the words of the post author, use that at your own risk.
For completeness, the first two of these don’t compile on g++-13 but the last one does.
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC optimize("O3")
#include <vector>
#pragma GCC target("avx")
int main() { std::vector<int> a; }
Cite this post
@online{target-pragma-bug-gcc-13-2024,
author = {nor},
title = {PSA: target pragmas won't work on the new g++-13 compiler on CF},
year = {2024},
month = {03},
day = {05},
url = {https://nor-blog.pages.dev/posts/2024-03-05-target-pragma-bug-gcc-13},
}