Sujet : Re: integer divided by zero
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 25. Apr 2025, 20:32:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vugo19$m2n2$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
Em 4/25/2025 4:05 PM, Keith Thompson escreveu:
Thiago Adams <thiago.adams@gmail.com> writes:
Does anyone know of any platform where integer division by zero
returns a number, or in other words, where it's not treated as an
error? I'm asking because division by zero is undefined behaviour, but
I think division by a constant zero should be a constraint instead.
Division by a constant zero is a constraint violation in a context that
requires a constant expression.
Consider this sample
int main(){
int a[1/0];
}
1/0 does not have a value in compile time,
So I believe compilers are making "a" a VLA because 1/0 is
not constant.
(But what old c89 compilers where doing in this case?)
This sample is a motivation to make integer divided by
zero a constrain.