moc crashes with an !isEmpty() assertion in QVector when preprocessing a file involving a ## operator with a left-hand side containing only whitespace in the dev branch. The expansions vector is emptied of all tokens and then constLast() is invoked on the empty vector.
This pattern is used in the standard type_traits header in upcoming releases of MSVC (as yet unreleased, but an upcoming preview of the next version of VS will contain this change). It's expressly permitted by the standard (see 16.3.3/p2 "If an argument consists of no preprocessing tokens, the parameter is replaced by a placemaker preprocessing token instead").
Attached is a small repro case that compiles with all of VC++, gcc, and clang but asserts with the debug moc in the dev or 5.8 branch. It does not crash in the 5.7 branch.
|For Gerrit Dashboard: QTBUG-55853|
|170698,2||moc: Fix asserts on moc on empty token preceding ## operator||5.8||qt/qtbase||Status: MERGED||+2||0|