Submitter:Fred Tydeman
Submission Date: 2018-12-12
Document: WG14 N2322
Reference Documents: N1911

Summary

SD3 item 9 against C2X: PreProcessor items unspecified.

Technical Corrigendum:

Add to §6.10.4 new paragraphs after paragraph 2.

If a preprocessing token (in particular __LINE__) spans two or more (physical) lines, it is unspecified which of those line numbers is associated with that token. If a pp-directive spans two or more (physical) lines, it is unspecified which of those line numbers is associated with the pp-directive. If a macro invocation spans multiple (physical or logical) lines, it is unspecified which of those line numbers is associated with that invocation. The line number of a preprocessing token is independent of the context (in particular, as a macro argument or in a pp-directive). The line number of a __LINE__ in a macro body is the line number of the macro invocation.

Recommended practice

The line number associated with a pp-token should be the line number of the first character of the pp-token. The line number associated with a pp-directive should be the line number of the line with the first # token. The line number associated with a macro invocation should be the line number of the first character of the macro name in the invocation.

Add to §J.1 Unspecified behavior

Existing practice

There is a large variation in existing implementations on the association between line numbers and pp-tokens, pp-directives, or macro invocations.