This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 12/01/2016 09:24 AM, Martin Sebor wrote:
So, let's use another testcase, -O2 -W -Wall -fno-tree-vrp -fno-tree-ccp and again UB in it: volatile bool e; volatile int x; int main () { x = 123; *(char *)&e = x; bool f = e; x = __builtin_snprintf (0, 0, "%d", f); } This will store 1 into x, while without -fprintf-return-value it would store 3.Great, that's what I was looking for. I turned it into the following test case. Let me try to massage it into a compile-only test suitable for the test suite and commit it later today.
I hadn't looked at the test case carefully enough when I said the above. Now that I have I see it fails even with your patch with VRP enabled) and I don't think that's a problem in GCC but rather in the test (the undefined behavior you mentioned). So I won't be adding it after all. I don't think it's appropriate to exercise behavior that we cannot or will not (or should not) guarantee. If you have a different test case does show the problem under these constraints I'm still interested. Martin
volatile bool e; volatile int x; #define FMT "%d" const char *fmt = FMT; int main () { x = 123; *(char *)&e = x; bool f = e; int n1 = __builtin_snprintf (0, 0, FMT, f); int n2 = __builtin_snprintf (0, 0, fmt, f); __builtin_printf ("%i == %i\n", n1, n2); if (n1 != n2) __builtin_abort (); } Martin
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |