------- Comment #8 from manu at gcc dot gnu dot org 2006-12-11 20:52 ------- (In reply to comment #5) > int x; > > enum e { E = 0 * x }; > > > which currently compiles without even a warning using -pedantic-errors. > This is exactly the sort of thing that Joseph's struct c_expr were intended > to handle. I don't think is unreasonable for fold to convert "0 * x" into > 0, the issue is that a front-end can't really look at a folded tree and > determine anything much about the original source code.
Should it warn? But back to the original case, we detect enum e { E = 0 * (INT_MAX + 1) }; by setting TREE_OVERFLOW. We could do the same for 1/0 and we just don't emit an overflow warning but a division by zero one. But this could be tricky. However, an alternative would be to prevent the folding for this specific case, so the resulting tree is not constant. We could try to detect this when folding 0*x (not sure how), or we could build something from 1/0 that will prevent folding 0*x (if such thing exists). Am I missing any other alternatives? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19976