It got me stuck for an hour. I happened to have a string constant with about 280 characters in it.
I was trying to use Pos to look for a substring within a long string constant. It gives the result 0 when the string is longer than 255 characters, but gives the correct result when the string is shorter.
e.g.:
pos('5', '123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.12345')
Containing 255 characters correctly returns the number 5.
pos('5', '123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456')
Containing 256 characters gives a compiler error: [DCC Error] E2056 String literals may have at most 255 elements.
pos('5', '123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1234567')
But 257 characters or more does not produce any messages and incorrectly returns the number 0.
This led me on a wild goose chase for a while.
I also found the same is true for a simple assignment to a string, e.g.:
S1 :='123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456';
gives that error message and won't compile.
But add one more character, and S1 is assigned a null string.
Is there a Delphi option that should be turned on to warn me of this, or is this just a "bug" by the Embarcadero programmers?
Could someone please check if Delphi 2010 now gives a message for all strings >= 255 characters, or for just 256 characters and not for those >= 257.
If not, how do I go about getting it noticed at Quality Central? I can't even figure out how to see if that problem has been reported.
Thanks for allowing me to vent.
Kornel's answer linked to a forum discussion that links to the bug report that says it has been fixed in build 14.0.3513.24210.
p.s. Don't you think Embarcadero should have eliminated the 255 limit when Delphi 2009's Unicode strings were introduced?