3

I have compiler warning in code while setting 32nd bit. Code works but this warning annoys me.

Compiler is Keil C, processor is 32 bit ARM. Code is as following

PINSEL0 |= PINSEL_AD15;

where PINSEL0 is 32 bit register, defined as

#define PINSEL0         (*((volatile unsigned long *) 0xE002C000))

and PINSEL_AD15 is defined like:

#define PINSEL_AD15  ((1<<30)|(1<<31)) 

The warning message I'm receiving is: integer operation result is out of range

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
Gossamer
  • 309
  • 2
  • 16

1 Answers1

9

The literal 1 is a signed integer, so when you shift by 31, you're going out of range. Try using an unsigned integer:

(1U << 31)
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680