Bug in method length() of Serial object ?

Hi all,

this morning I got the infamous issue relocation truncated to fit: R_AVR_13_PCREL... Forrunately, i traced it to

			if (XCmd.Data.length() > 3)  // That line creates the issue
				{
				XFrame.Ok = false;
				return 1;
				}

If I change the code to

			XCmd.Data.toCharArray(chCmd, 25);
			
			if (strlen(chCmd) > 3)
				{
				XFrame.Ok = false;
				return 1;
				}

Everything is fine :~. This is with version 1.0.5 of the IDE.

Reading other posts I thought that this bug was fixed, but looks like not. IS there an issue with the Serial class, or with the gc compiler ?

Thanks

Looks like there is a problem with the XCmd class, don't you mean ?

XCmd is a structure whose Data member is a String object (XCmd.Data). Then the issue is outside my code.

You said “Serial object”, but I think you mean “String object” ? They’re not related, particularly.
String objects have a bunch of issues, to the point where many of the curmudgeons on the forums recommend that they be avoided entirely. But I don’t think I’ve seen this particular problem before…

Which Arduino are you compiling for?

Oh boy, yes I am talking about a String object :blush:

The board is a Sparkfun Mega Pro 3.3 V (some kind of Mega 2560). I came across that error message on the forum: lots of questions, but no answer :~. When you find out the line that triggers it, you can easily go around, but if you don't know the line, it's a nightmare.