forked from Eelis/geordi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
19 lines (11 loc) · 1.16 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Output separators
Consider the following two snippets:
geordi { cout << *(int*)0; }
geordi { cout << 3 << flush; cout << *(int*)0; }
We want these to output "Undefined behavior detected" and "3 Undefined behavior detected", respectively. Note that a space was added in the second result but not the first. Next, consider:
geordi: { tracked::B x, y; cout << 'a'; }
We want this to output "B0* B1* a B1~ B0~". Note that not every tracking message is preceded by a space of its own, nor is every tracking message followed by one.
Geordi has a systematic way of dealing with these situations where we only want a space to be inserted if required to separate things. The mechanism is as follows:
1. The program outputs the Unicode character PARAGRAPH SEPARATOR (U+2029) whenever separation is desired.
2. EvalCxx.hsc erases any U+2029's occurring at the beginning and end of the output, and replaces any other sequence of successive U+2029's with a single space.
For the above examples, the desired output can now be easily achieved by outputting an U+2029 before "Undefined behavior detected", and by outputting U+2029's before and after each tracking message.