https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84595

            Bug ID: 84595
           Summary: __builtin_trap() causes optimizer to remove code
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danielgutson at gmail dot com
  Target Milestone: ---

__builtin_trap() cannot be used as a breakpointing mechanism because the
optimizer removes all subsequent code:

#include <stdio.h>

int main()
{
        __builtin_trap();
        printf("hello world\n");
        return 0;
}


Then

main:
  ud2

I propose, as a feature, either to provide a new command line option to control
whether the code is optimized out or preserved, or to a add a new builtin
function.

Reply via email to