Scientists complete Schrödinger's 100-year-old color theory
sciencedaily.com5 pointsby cokernel_hacker1 comments
typedef int (*pfn)(void);
int g(void);
int h(void);
pfn f(double x) {
switch ((long long)x) {
case 0:
return g;
case 17:
return h;
}
}
If I understand your perspective correctly, `f` should return whatever happens to be in rax if the caller does not pass in a number which truncates to 0 or 17? int f(int x) {
switch (x) {
case 0:
return 31;
case 1:
return 28;
case 2:
return 30;
}
}
This code on its own has no undefined behavior. int f(int x) {
static int y[] = {42, 43};
return y[x];
}
What behavior should `f(-1)` or `f(100)` have? What is sensible? >>> [ord(x) ^ ord(y) for (x, y) in zip("windows", "sindogs")]
[4, 0, 0, 0, 0, 16, 0]
Sure enough... struct S { int large[100]; };
int compliant(struct S a, const struct S *b);
int escape(const void *x);
int bad() {
struct S s;
escape(&s);
return compliant(s, &s);
}
int compliant(struct S a, const struct S *b) {
int r = &a != b;
escape(&a);
escape(b);
return r;
}
There are three calls to 'escape'. A programmer may assume that the first and third call to escape observes a different object than the second call to escape and they may assume that 'compliant' returns '1'.
"The Geometry of Color in the Light of a Non-Riemannian Space"
https://onlinelibrary.wiley.com/doi/10.1111/cgf.70136