title: How to tell gcc to keep my unused labels?
body: <p><strong>Edit:</strong> Thanks to @NateEldredge, I better defined my question in <a href="https://stackoverflow.com/questions/70089766/how-to-tag-a-location-in-a-c-source-file-for-a-later-breakpoint-definition">How to &#39;tag&#39; a location in a C source file for a later breakpoint definition?</a></p>
  <hr />
  <p>I use those labels to setup breakpoints in gdb. So no matter if I add/remove lines of code after/before the label, the breakpoint is still correct.</p>
  <p>If I add <code>-Wno-error=unused-label</code> to the compilation options, the compiler does not yell at me, but the label disappears from the assembly.</p>
  <p>If instead, I use <code>__attribute__((unused))</code> in the code, the result is the same: no complain, but the label is gone.</p>
  <p>Is there a correct way of getting this done (instead of just a hack)?</p>
  <p>Here is my toy example:</p>
  <pre><code>int main(void){
      int a = 15;
   label: __attribute__((unused))
      a = a + 23;
      return a;
  }
  </code></pre>
  <p>After compilation, it results in:</p>
  <pre><code>main:
          push    ebp
          mov     ebp, esp
          sub     esp, 16
          mov     DWORD PTR [ebp-4], 15
          add     DWORD PTR [ebp-4], 23
          mov     eax, DWORD PTR [ebp-4]
          leave
          ret
  </code></pre>
  <p>Here an interactive version of the same example: <a href="https://godbolt.org/z/zTqd9bM6q" rel="nofollow noreferrer">https://godbolt.org/z/zTqd9bM6q</a></p>
  <hr />
  <pre class="lang-sh prettyprint-override"><code>$ gcc --version
  gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)
  Copyright (C) 2020 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  </code></pre>