Input: int main() { int a; asm("" : "=d"(a) : "0"(a), "0ae"(&a)); } Output: $ cc1plus int main() Analyzing compilation unit Performing interprocedural optimizations <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <targetclone> <free-fnsummary> <whole-program> <fnsummary> <inline> <free-fnsummary> <single-use> <comdats>Assembling functions: <materialize-all-clones> <simdclone> int main()during RTL pass: reload <stdin>: In function 'int main()': <stdin>:4:1: internal compiler error: in match_reload, at lra-constraints.c:1068 0x287e277 match_reload /home/vegard/git/gcc/gcc/lra-constraints.c:1066 0x28ade79 curr_insn_transform /home/vegard/git/gcc/gcc/lra-constraints.c:4335 0x28b93b6 lra_constraints(bool) /home/vegard/git/gcc/gcc/lra-constraints.c:4877 0x2829984 lra(_IO_FILE*) /home/vegard/git/gcc/gcc/lra.c:2419 0x2608794 do_reload /home/vegard/git/gcc/gcc/ira.c:5465 0x2608794 execute /home/vegard/git/gcc/gcc/ira.c:5649 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Version: GNU C++14 (GCC) version 8.0.1 20180306 (experimental) (x86_64-pc-linux-gnu) 7.3.0 seems to handle it and outputs: main: pushq %rbp movq %rsp, %rbp movl -4(%rbp), %eax leaq -4(%rbp), %rcx movl %eax, %edx movl %edx, %eax movl %eax, -4(%rbp) movl $0, %eax popq %rbp ret Clang says: <source>:3:36: error: more than one input constraint matches the same output '0' asm("" : "=d"(a) : "0"(a), "0ae"(&a)); ^ <source>:3:26: note: constraint '0' is already present here asm("" : "=d"(a) : "0"(a), "0ae"(&a)); ^ 1 error generated. Compiler returned: 1
Started with r192719. Before that it has been rejected with: pr84985.c: In function ‘main’: pr84985.c:3:3: error: ‘asm’ operand has impossible constraints asm("" : "=d"(a) : "0"(a), "0ae"(&a)); ^ Only ICEs with -O0, at -O2 it passes. ICEs even with int a = 1; instead of just int a;, so there is no uninitialized use. int main() { int a = 1; asm("" : "=d"(a) : "0"(a), "0r"(&a)); } ICEs too, but "=r" or "=a" instead does not. I don't see anything invalid on it, unless it is just "0"(a), "0"(&a) which is of course impossible to reload and is properly diagnosed: pr84985.c: In function ‘main’: pr84985.c:3:3: error: inconsistent operand constraints in an ‘asm’ asm("" : "=d"(a) : "0"(a), "0"(&a)); ^~~
With -std=c++14 ICE on 4.9.0+.
Author: vmakarov Date: Thu Mar 29 18:29:12 2018 New Revision: 258961 URL: https://gcc.gnu.org/viewcvs?rev=258961&root=gcc&view=rev Log: 2018-03-29 Vladimir Makarov <vmakarov@redhat.com> PR inline-asm/84985 * lra-constraints.c (process_alt_operands): Move setting this_alternative_matches below. 2018-03-29 Vladimir Makarov <vmakarov@redhat.com> PR inline-asm/84985 * gcc.target/i386/pr84985.c: New. Added: trunk/gcc/testsuite/gcc.target/i386/pr84985.c Modified: trunk/gcc/ChangeLog trunk/gcc/lra-constraints.c trunk/gcc/testsuite/ChangeLog
GCC 6 branch is being closed
Fixed in GCC 8.