Title
Undesirable formation of import directive with string-literal
Status
tentatively ready
Section
15.1 [cpp.pre]
Submitter
Hubert Tong

Created on 2025-09-22.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-09-26.20:51:59

Proposed resolution (approved by CWG 2025-09-26):

Change in 15.1 [cpp.pre] bullet 1.2 as follows:

  • ...
  • an import preprocessing token immediately followed on the same logical source line by a header-name, <, identifier, string-literal, or : preprocessing token, or
  • ...
Date: 2025-09-22.20:52:33

(From submission #769.)

Consider:

  #define STR(X) #X
  const char *str = STR(
  import u8"hello";     // #1
  );

Line #1 is recognized as an import directive, even though the eventual attempt to form a header-name will be IFNDR (see issue 3076). This is incongruent with the stated design goal of P1857: since a header-name is lexed right away, any string-literals that remain are necessarily invalid.

History
Date User Action Args
2025-09-26 20:51:59adminsetstatus: open -> tentatively ready
2025-09-22 20:37:55adminsetmessages: + msg8121
2025-09-22 00:00:00admincreate