title: Why is the C preprocessor a subject of undefined behavior?
body: <p>I can understand that:</p>
  <ul>
  <li>One of the origins of the UB is a performance increase (e.g. by removing never executed code, such as <code>if (i+1 &lt; i) { /* never_executed_code */ }</code>; UPD: if <code>i</code> is a signed integer).</li>
  <li>UB can be triggered at compile time because C does not clearly distinguish between compile time and run time. The &quot;whole language is based on the (rather unhelpful) concept of an &quot;abstract machine&quot; (<a href="https://stackoverflow.com/a/67266324/1778275">link</a>).</li>
  </ul>
  <p>However, I cannot understand yet why C preprocessor is a subject of undefined behavior? It is known that preprocessing directives are executed at compile time.</p>
  <p>Consider C11, 6.10.3.3 The ## operator, 3:</p>
  <blockquote>
  <p>If the result is not a valid preprocessing token, the behavior is undefined.</p>
  </blockquote>
  <p>Why not make it a constraint? For example:</p>
  <blockquote>
  <p>The result shall be a valid preprocessing token.</p>
  </blockquote>
  <p>The same question goes for all the other &quot;the behavior is undefined&quot; in 6.10 Preprocessing directives.</p>