What part of the instruction: "priority is to be assigned only by an approved MinGW developer" do you not understand? You are not such a developer. Thus your attempt to escalate priority guarantees that this ticket will be treated as lowest priority.
This is not specifically a MinGW bug. Yes, I can see that it misbehaves as you suggest, but it exhibits similar misbehaviour when I compile it as a native GNU/Linux application, (using GCC-10.2 on Manjaro Linux). If you want it pursued, you need to raise the issue on the GCC bug tracker.
You really should not use #include <bits/stdc++.h> directly in user code; that's an internal-use header. In this example, you should be using #include <iostream>.
If I compile your code, I see a warning about a missing return statement, in your non-void f() function. Address that warning, either by adding the missing return statement, or by declaring void f(), and the misbehaviour does not occur.
This Piece of Code is getting Stuck In Infinite Loop when Using -O2 Flag