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

            Bug ID: 98846
           Summary: Spurious -Wregister warning
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: programmerjake at gmail dot com
  Target Milestone: ---

In:
https://gcc.godbolt.org/z/49xoKP

With the following code:

template <typename T = void>
int template_get_edx() {
    register int edx asm("edx");
    asm("movl $1234, %%edx\n\t# reg=%0" : "=r"(edx));
    return edx;
}

template int template_get_edx<void>();

With: -O -Wall -std=c++17

produces:
<source>: In instantiation of 'int template_get_edx() [with T = void]':
<source>:8:37:   required from here
<source>:3:18: warning: ISO C++17 does not allow 'register' storage class
specifier [-Wregister]
    3 |     register int edx asm("edx");

I think that warning is spurious because the `register` keyword is required for
clang to not ignore the asm("edx").
  • [Bug c++/98846] New: Spurious... programmerjake at gmail dot com via Gcc-bugs

Reply via email to