On Wed, 14 Feb 2024 08:26:41 +0100 Matthias Klose <d...@debian.org> wrote: > Control: tags -1 + moreinfo > > On 14.02.24 02:10, VictorBW wrote: > > Package: gcc > > Version: 4:12.2.0-3 > > Severity: normal > > X-Debbugs-Cc: knodewaeee+debb...@gmail.com > > > > Dear Maintainer, > > > > I wanted to dynamically select registers for use in an inline assembly statement, so I tried the questionmark conditional operator, as in this minimal example: > > > > namespace gpr { > > volatile register int64_t r12 asm("r12"); > > volatile register int64_t r13 asm("r13"); > > ... > > asm volatile ("mov %0, blah" : "+r"((reg) ? gpr::r13 : gpr::r12)); > > > > please post the complete code example. > > please also recheck with newer GCC versions (GCC 13, GCC 14) in newer > Debian development versions. > I do not have GCC 13/14 installed, but godbolt.org's copy of GCC 13 and trunk will not compile the following complete example
int main(int argc, char** argv) { register long reg_1 asm("r12"); register long reg_2 asm("r13"); asm volatile ("mov %0, %%r11" : "+r"((argc) ? reg_2 : reg_1)); } I note that in C mode (gcc minbug.c) a different error is produced (error: lvalue required in ‘asm’ statement), but in C++ mode (g++ minbug.c) we get the internal compiler error, and that selecting an input parameter the same way (rather than an output parameter) seems to work correctly.