View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0021951FPCCompilerpublic2012-05-06 05:592012-05-06 16:57
ReporterMichalis Kamburelis 
Assigned ToJonas Maebe 
Platformi386OSDebian GNU/LinuxOS Version(testing)
Product VersionProduct Build 
Target VersionFixed in Version 
Summary0021951: Using any {$modeswitch xxx} overrides -Sh as specified on the command line
DescriptionAs far as I understand, the purpose of $modeswitch is to change a particular syntax behavior --- without touching any other behavior. But it seems that using {$modeswitch nestedprocvars} also implicitly changes the state of $H switch: it makes string=ShortString (which is probably something you seldom want in modern code).

Compiling the attached testcase with -Sh:

$ fpc -Mobjfpc -Sh nestedprocvars_string.pas
$ ./nestedprocvars_string

Adding {$H+} in the source code (after or *before* {$modeswitch nestedprocvars}) makes it work Ok: string remains equal to AnsiString. The testcase then correctly prints 1000 and 'a' * 1000.

On the command-line, -Mnestedprocvars also seems to activate shortstrings, this time only if it's after -Sh. So if you remove {$modeswitch nestedprocvars} from the attached testcase, and try

  fpc -Mobjfpc -Sh -Mnestedprocvars nestedprocvars_string.pas

then string=ShortString. But

  fpc -Mobjfpc -Mnestedprocvars -Sh nestedprocvars_string.pas

is correct: string remains AnsiString.

I think it would be cleaner if -Mnestedprocvars and {$modeswitch nestedprocvars} just didn't touch the state of $H at all. These two features (longstrings and nested procs) seem completely unrelated and orthogonal.

Tested with FPC 2.6.0 and 2.7.1 (SVN state from 2012-04-22, revision 20993).
TagsNo tags attached.
Fixed in Revision21247
Attached Files? file icon nestedprocvars_string.pas [^] (335 bytes) 2012-05-06 05:59

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2012-05-06 05:59 Michalis Kamburelis New Issue
2012-05-06 05:59 Michalis Kamburelis File Added: nestedprocvars_string.pas
2012-05-06 15:59 Jonas Maebe FPCOldBugId => 0
2012-05-06 15:59 Jonas Maebe Summary Using {$modeswitch nestedprocvars} makes string=ShortString => Using any {$modeswitch xxx} overrides -Sh as specified on the command line
2012-05-06 16:27 Jonas Maebe Status new => assigned
2012-05-06 16:27 Jonas Maebe Assigned To => Jonas Maebe
2012-05-06 16:57 Jonas Maebe Fixed in Revision => 21247
2012-05-06 16:57 Jonas Maebe Status assigned => resolved
2012-05-06 16:57 Jonas Maebe Resolution open => fixed

MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker