Hi! We have many loops that use CONSTRAINT_LEN to skip over various constraint characters, but we assume the constraints have valid length and don't walk the individual characters to double check this.
If that is not the case, when e.g. 2 character constraint starting letter is followed by '\0', we'd reject it early (during vregs pass, through asm_operand_ok). The PR has different testcase (that fails randomly based on ASLR), where a 2 character constraint starting letter is followed by ',', and several spots expect that not to happen (they count number of alternatives and then for each alternative walk with skipping CONSTRAINT_LEN characters). This patch diagnoses this problematic case early as well. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-08 Jakub Jelinek <ja...@redhat.com> PR inline-asm/84742 * recog.c (asm_operand_ok): Return 0 if multi-character constraint has ',' character inside of it. * gcc.target/i386/pr84742-1.c: New test. * gcc.target/i386/pr84742-2.c: New test. --- gcc/recog.c.jj 2018-01-16 09:53:47.000000000 +0100 +++ gcc/recog.c 2018-03-08 14:04:35.889274871 +0100 @@ -1825,7 +1825,7 @@ asm_operand_ok (rtx op, const char *cons len = CONSTRAINT_LEN (c, constraint); do constraint++; - while (--len && *constraint); + while (--len && *constraint && *constraint != ','); if (len) return 0; } --- gcc/testsuite/gcc.target/i386/pr84742-1.c.jj 2018-03-08 14:11:20.155463943 +0100 +++ gcc/testsuite/gcc.target/i386/pr84742-1.c 2018-03-08 14:12:28.453495882 +0100 @@ -0,0 +1,10 @@ +/* PR inline-asm/84742 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo () +{ + char b = 1; + asm volatile ("" : "+T,Y" (b)); /* { dg-error "impossible constraint in 'asm'" } */ +} --- gcc/testsuite/gcc.target/i386/pr84742-2.c.jj 2018-03-08 14:12:37.205499976 +0100 +++ gcc/testsuite/gcc.target/i386/pr84742-2.c 2018-03-08 14:12:52.150506968 +0100 @@ -0,0 +1,10 @@ +/* PR inline-asm/84742 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo () +{ + char b = 1; + asm volatile ("" : "+gT,m" (b)); /* { dg-error "impossible constraint in 'asm'" } */ +} Jakub