Looking at the information for the gcc package, it appears that F37 is still using gcc 12.X.
So the easiest method would be to create a F37 toolbox and install gcc there.
toolbox create -r 37
toolbox enter fedora-toolbox-37
If you need a F38 toolbox for some reason, you can try downloading a 12.X build from koji and installing that way. Though in my brief experiments, I ran into a dependency hell that would be difficult to solve manually.