After a few days, I stopped searching online and kept reading the docs, which led me to the following section: 17.7.3 Compiler search for the compile command.
Then, In my gdb session, I executed the following command - which would set the gdb to use gcc-14 (from gcc-13 being the incompatible version).
(gdb) set compile-gcc x86_64-linux-gnu-gcc-14
(gdb) compile code i = 4; // success
(gdb)
This resolved it and there were no compilation failures whatsoever.