A raw string literal ends at the first )", even inside a quoted pattern
PitfallVerified 28 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A test that embeds a query or regex in a raw string literal fails to compile with a burst of unrelated-looking errors:
test_prefilter.cpp:43:37: error: expected '}'
test_prefilter.cpp:43:44: error: use of undeclared identifier 'name'
test_prefilter.cpp:43:59: warning: missing terminating '"' character [-Winvalid-pp-token]
The line was:
R"(name ~ "(cuda|hip)")"
Cause#
R"(...)" ends at the first )" in the text. A pattern whose last character before its closing quote is ) (a group at the end: "(cuda|hip)", "a(?=b)", extract(p, "run_([0-9]+)", 1)) contains )" and ends the literal early.
Fix#
Give such literals a delimiter that cannot occur in the text:
R"q(name ~ "(cuda|hip)")q"
Use it for every literal that holds a regex or a group, not only the ones that fail today.
Evidence#
- dftracer-utils
tests/index/test_prefilter.cppandtests/duql/test_patterns.cpp(2026-09-28): 11 literals with regex groups failed to compile asR"(...)"and compiled and passed asR"q(...)q".