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]

Re: [C++ PATCH] Rewrite convert_nontype_argument (take 2)


Giovanni Bajo wrote:

Mark Mitchell wrote:



I'm nervous about the warning->error change for division by zero in
build_binary_op; isn't this a valid C++ function:

int f(int i) { return i / 0; }

even though any call to it will result in undefined behavior?



Yes, you are right, we should not reject this and my change to build_binary_op is invalid (it didn't trigger in a full test cycle though, I will add a testcase like the one you proposed later with my patch).

The problem is that when we tsubst A%B (for either A or B template parameters),
we end up with an expression like "3 % 0" marked with TREE_CONSTANT but that is
not a constant expression in the C++ sense (I can't allow it as a template
argument, as far as I can tell).


No, you can't -- and, in fact, I think that if division-by-zero occurs in an expression that is an integral constant-expression (e.g., an array bound, or an enumeration constant) we should definitely be issuing an error.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]