C code optimization using #pragma GCC optimize

后端 未结 2 701
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 08:47

I am trying to use the GCC pragma optimize to set global optimizations in my C code. GCC version is 4.4.3 on Ubuntu. The basic idea is to use function specific optimization leve

相关标签:
2条回答
  • 2021-01-21 09:13

    An ICE (internal compiler error) leading to a segmentation fault is always a bug in the compiler, which is why it asks you to report the bug. You should not be able to crash the compiler with any source code, valid or invalid. (There are all sorts of things that may happen, most often involving a refusal to compile invalid code, but crash isn't one of them.)

    Since GCC 4.6.1 is current, why not consider an upgrade to a more recent version of GCC (not that 4.4.3 is all that old).

    Before submitting a bug report, you should try to minimize your reproduction. Everything from line 494 onwards is probably immaterial; with luck, you can reduce the material between lines 1 and 493 from almost 500 down to 20 or so. You should certainly aim to reduce it as much as possible while preserving the error. Before you start chopping the code, preserve the version that crashes the compiler. As you successfully remove the code while preserving the crash, check each successive version into your VCS. (You are using a VCS, aren't you? That's a rhetorical question; if you're not, now's a good time to start. You need one to avoid making changes that can't be undone.) Try to eliminate non-standard headers (ones you've written) before eliminating standard headers. Try to get rid of as many headers as possible. Note the request for preprocessed source - the code reduction I'm talking of reduces the size of the preprocessed source.

    0 讨论(0)
  • 2021-01-21 09:17

    For the last question: you could put it into a separate compilation unit and use the command line switch: -O3

    0 讨论(0)
提交回复
热议问题