Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-04

Submitted bug report on option order -Sa -Sg-

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Verhoeff

I just submitted a bug report (8686) on an option order problem involving assertion checking (-Sa).

We got bitten badly by this, since it affects our automatic homework checker (PEACH), that also tests to see if expected exceptions are indeed raised. E.g. students need to include appropriate Assert statements in their programs to check critical preconditions. Such testing is not much use when no assertion checking code is generated by the compiler.

Last year everything worked fine, and now it failed. It turns out that since last year we added the compiler option -Sg- to prevent students from using goto statements in their code.

The order -Sa -Sg- fails to generate assertion checking code, whereas this is generated for the order -Sg- -Sa.

A separate test confirms this (mis)behavior (see bug report: Steps To Reproduce).

Or am I missing the obvious, and is this really a feature and not a bug?

Tom

E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven http://www.win.tue.nl/~wstomv/ | The Netherlands

Reply by email

Jonas Maebe
to Tom Verhoeff
Tom Verhoeff wrote 8 lines
The order -Sa -Sg- fails to generate assertion checking code, whereas this is generated for the order -Sg- -Sa. A separate test confirms this (mis)behavior (see bug report: Steps To Reproduce). Or am I missing the obvious, and is this really a feature and not a bug?

-S- disables all the -S options, regardless of where the second - appears (like -O- disables all -O options). This can indeed be confusing, since e.g. -Cor- turns on overflow checking, but disables range checking. This is indeed not consistent. Both cases work as designed, but the design is obviously not optimal.

Jonas

Reply by email

Tom Verhoeff
Tomas Hajny wrote 55 lines
On 15 Apr 07, at 21:14, Tom Verhoeff wrote: > On Sat, Apr 14, 2007 at 06:56:12PM +0200, Jonas Maebe wrote: > > On 13 Apr 2007, at 17:38, Tom Verhoeff wrote: > > > > >The order -Sa -Sg- fails to generate assertion checking code, whereas > > >this is generated for the order -Sg- -Sa. > > > > > >A separate test confirms this (mis)behavior (see bug report: Steps To > > >Reproduce). > > > > > >Or am I missing the obvious, and is this really a feature and not a > > >bug? > > > > -S- disables all the -S options, regardless of where the second - > > appears (like -O- disables all -O options). This can indeed be > > confusing, since e.g. -Cor- turns on overflow checking, but disables > > range checking. This is indeed not consistent. Both cases work as > > designed, but the design is obviously not optimal. > > Thanks for the explanation. I think I understand what you are saying. > > In the (on-line) User's Guide, I can't find anything about the use of > a trailing - for options. Where is this documented? > > How would one disable just the goto statement, without affecting other > -S options? > > By the way, the User's Guide states that goto statements are disabled > by default. However, the reason we added the -Sg- (attempting to disable > just goto statements) was because after upgrading, suddenly programs > with goto were accepted (and we don't want that in our educational use > of Pascal). Hence, we added the option. The default mode is -Mfpc nowadays. Modes FPC and OBJFPC don't have goto enabled by default (i.e. - Sg is required to enable it), so the docs are correct (modes TP and Delphi both have -Sg enabled for compatibility reasons). > Could it be that the default configuration file also got changed by the > update and now enables goto statements? (This would be confusing.) This seems to be the case indeed (see /fpcsrc/compiler/utils/samplecfg, /fpcsrc/compiler/utils/fpc.cft, /fpcsrc/compiler/utils/fpinc.cfg and /fpcsrc/installer/install.dat). General question - do we want to change this (taking into account that having some default in the compiler and then changing it into something different in the default configuration file looks strange)? If nothing else, you can obviously change this in your own configuration files, of course.

So, it is now not possible to switch off goto statements in Delphi mode by just giving some command-line options. It requires an adapted configuration file, or knowing exactly what options are implicitly set for -Mdelphi, and copying those, except -Sg, on the command-line. Or do I overlook a simpler possbility?

My question about where -O-, -S-, and -Cx- are documented is still open... (I like to read manuals, but couldn't find anything.)

I have added a clarifying note to my original bug report (#0008686). The original bug report is thereby resolved, but there are still some related open ends:

* Documentation explaining -Sxxx-
* Defaults in standard config file(s) versus defaults for compiler (w/o config file)
* Simpler way to switch off single -S options

Thanks,

Tom

E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven http://www.win.tue.nl/~wstomv/ | The Netherlands

Reply by email

Peter Vreman
to Tom Verhoeff
Show quoted text 5 lines
So, it is now not possible to switch off goto statements in Delphi mode by just giving some command-line options. It requires an adapted configuration file, or knowing exactly what options are implicitly set for -Mdelphi, and copying those, except -Sg, on the command-line. Or do I overlook a simpler possbility?

Add {$goto off} to the source.

Reply by email

Micha Nelissen
to Peter Vreman
Peter Vreman wrote 7 lines
> So, it is now not possible to switch off goto statements in Delphi > mode by just giving some command-line options. It requires an adapted > configuration file, or knowing exactly what options are implicitly > set for -Mdelphi, and copying those, except -Sg, on the command-line. > Or do I overlook a simpler possbility? Add {$goto off} to the source.

That would require to modify the source sent to him, not ideal, I think. However, if students would write ${goto on} in the source, that would take precedence over commandline anyway ?

Micha

Reply by email