3 ms·
I think it's describing a particular lexer or preprocessor bug that GCC never had, so "a + = 1" should have been a syntax error in C89 as well. Someone mirror
by omoikane 2y ago
I think it's describing a particular lexer or preprocessor bug that GCC never had, so "a + = 1" should have been a syntax error in C89 as well.
Someone mirrored GCC 0.9 (1987), the relevant bits start here:
https://github.com/huangguiyang/gcc-0.9/blob/a83ea1b45dc3187d9fc4f7a3d8091c1454991afe/parse.y#L1296 https://github.com/huangguiyang/gcc-0.9/blob/a83ea1b45dc3187...
// Read the next non-whitespace character.
1296: c = skip_white_space();
// Match it against '+'
1618: case '+':
// Tentatively give it the token 'PLUS_EXPR'
1637: case '+':
1638: yylval.code = PLUS_EXPR; break;
// Read the next character, but note that whitespaces are NOT skipped here.
1663: c1 = getc(finput);
// Match the second character against '='
1665: if (c1 == '=')
...
1678: value = ASSIGN; goto done;
// Unread the next charcter if it didn't match.
1700: ungetc (c1, finput);
"a +/* */= 1" wouldn't have parsed either, because /**/ are translated to spaces by the preprocessor.
https://github.com/huangguiyang/gcc-0.9/blob/a83ea1b45dc3187d9fc4f7a3d8091c1454991afe/cccp.c#L974 https://github.com/huangguiyang/gcc-0.9/blob/a83ea1b45dc3187...*
- MaxBarraclough 2y agoThe article isn't very clear but on closer reading I think it's describing quirks of certain compilers in the pre-standardisation era, which it calls older versions of C. At the risk of splitting hairs: at the time I'm not sure it would have been considered a bug.