433 1019 Warning: Source size may exceed destination size

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

433 1019 Warning: Source size may exceed destination size

#1 Post by JimKueneman » 14 Mar 2010 15:39

How can you use string concatenation and not get this warning?

I have this:

Code: Select all

const
  VERSION_STRING = 'V100 03 07 2010';  // 12 characters with spaces not counted
var
  s: string[20];
begin
  s := VERSION_STRING + #13;  // Compiler only deals with 2 operands at a time in this version
  s := s + 'O';
  s := s + #13;
  UART1_Write_Text(s);
  ......
I count 18 characters and have defined a 20 character string. There should be no way I exceed the destination. This warning occurs everywhere I use the "+" operator.

Jim

Bryn
Posts: 26
Joined: 18 Apr 2009 12:38

Re: 433 1019 Warning: Source size may exceed destination siz

#2 Post by Bryn » 14 Mar 2010 19:30

Code space is too valuable to include run-time array bounds checking so the compiler is just giving you a friendly little warning to be extra careful when using string manipulation which may affect a string's length.
I read it as "please; double-check that your string lengths are Ok" :D
To err is human; to moo, bovine.

JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Re: 433 1019 Warning: Source size may exceed destination siz

#3 Post by JimKueneman » 14 Mar 2010 23:26

But usually there is a way to suppress warnings to tell a compiler "Yes I know what I am doing". :wink:


Jim

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Re: 433 1019 Warning: Source size may exceed destination siz

#4 Post by OT » 15 Mar 2010 06:22

JimKueneman wrote:But usually there is a way to suppress warnings to tell a compiler "Yes I know what I am doing". :wink:

Jim
Yes, untick the "warning" and "hints" and the messages will be all gone, only errors show up. :D

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”