mirror of https://gerrit.osmocom.org/asn1c
unbreak overflow detection in gcc 4.4.3 (4.x?)
This commit is contained in:
parent
e8727ec286
commit
9a338f8d25
|
@ -314,7 +314,8 @@ asn_GT2time_prec(const GeneralizedTime_t *st, int *frac_value, int frac_digits,
|
|||
while(fd > frac_digits)
|
||||
fv /= 10, fd--;
|
||||
while(fd < frac_digits) {
|
||||
int new_fv = fv * 10;
|
||||
int volatile new_fv = fv * 10;
|
||||
/* GCC 4.x is being too smart without volatile */
|
||||
if(new_fv / 10 != fv) {
|
||||
/* Too long precision request */
|
||||
fv = 0;
|
||||
|
@ -441,7 +442,8 @@ asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, int *frac_digits,
|
|||
*/
|
||||
for(buf++; buf < end; buf++) {
|
||||
int v = *buf;
|
||||
int new_fvalue;
|
||||
int volatile new_fvalue;
|
||||
/* GCC 4.x is being too smart without volatile */
|
||||
switch(v) {
|
||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
|
||||
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
||||
|
|
|
@ -396,7 +396,9 @@ INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
|
|||
}
|
||||
|
||||
{
|
||||
long new_value = value * 10;
|
||||
long volatile new_value = value * 10;
|
||||
/* GCC 4.x optimizes (new_value) without `volatile'
|
||||
* so the following check does not detect overflow. */
|
||||
|
||||
if(new_value / 10 != value)
|
||||
/* Overflow */
|
||||
|
|
|
@ -691,7 +691,8 @@ OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length,
|
|||
value = 0;
|
||||
}
|
||||
if(1) {
|
||||
long new_value = value * 10;
|
||||
long volatile new_value = value * 10;
|
||||
/* GCC 4.x is being too smart without volatile */
|
||||
if(new_value / 10 != value
|
||||
|| (value = new_value + (*oid_text - 0x30)) < 0) {
|
||||
/* Overflow */
|
||||
|
|
Loading…
Reference in New Issue