freemint / m68k-atari-mint-gcc

Fork of GNU's gcc with support for the m68k-atari-mint target
https://github.com/freemint/m68k-atari-mint-gcc/wiki
Other
27 stars 7 forks source link

c++ still producing trap #7 instruction #44

Open th-otto opened 5 months ago

th-otto commented 5 months ago

In some larger projects, i noticed that especially the c++ compiler still produces trap #7 instructions. That is maybe a relict from the linux version, and comes from the expansion of __builtin_trap https://github.com/freemint/m68k-atari-mint-gcc/blob/4598322acf7f9abe94721449c100f782185f05df/gcc/config/m68k/m68k.md#L7574

I don't know yet however what is actually causing this. I thought it might have something to do with __builtin_unreachable or functions being declared as noreturn, but i was not yet able to reproduce this with a simple testcase.

Do you think we should fix this, maybe by changing that to abort() instead?

vinriviere commented 5 months ago

Oh. Would it be possible to have a simplified testcase to produce such thing? That would help, i.e. to open a bug on GCC Bugzilla, if relevant.

th-otto commented 5 months ago

I already tried to produce a small testcase, without luck. Maybe i should try with cvise again, but that is slow.

But its not a bug, the __builtin_trap function is defined that way. We just need to know which circumstances cause it to be used, and then maybe replace the trap by something different.

John-Titor commented 5 months ago

The usual case for this is when code paths are elided due to UB detection.