Content originally posted in LPCWare by lpcxpresso-support on Tue Dec 15 10:24:57 MST 2015
GCC's way of treating assembler as unified syntax (or not) has tended to change slightly over releases, and also between different Cortex-M variants.
It always possible if your project has been underway for a long time that you are using a vintage version of the startup file which assumed a gcc behaviour that has now changed.
However your assertion that you see different behaviour at- O0 vs -O2 makes little sense, perhaps unless the code in question is being inlined (or not inlined). But without seeing your actual project and knowing what version of the tools you are using, it is hard to comment further.
Regards,
LPCXpresso Support