Delphi 7 versus Delphi 2010 compiler directive {$Q-}

Hi,

Could it be correct that there's a bug in Delphi7 where the compiler directive {$Q-} and {$Q+} works completely the 
opposite?

When trying to build an existing Delhi 7 project in Delphi 2010 i found this weird behaviour.
In D7 {$Q-} set overflow cheking on and in Delphi 2010 off ?????

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database with many powerful SQL features:
  http://www.firebirdsql.org
  http://www.firebirdsql.info

General database developer support:
  http://www.databasedevelopmentforum.com

Support list for Interbase and Firebird users:
  firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
  news://newsgroups.firebirdsql.info
0
Arno
2/2/2010 9:44:13 AM
embarcadero.delphi.ide 3925 articles. 0 followers. Follow

5 Replies
1779 Views

Similar Articles

[PageSpeed] 6

Arno Brinkman wrote:

> Could it be correct that there's a bug in Delphi7 where the compiler
> directive {$Q-} and {$Q+} works completely the opposite?

Assuming D7 build 8.1, not very likely.
 
> When trying to build an existing Delhi 7 project in Delphi 2010 i
> found this weird behaviour.  In D7 {$Q-} set overflow cheking on and
> in Delphi 2010 off ?????

Could it be that you use include files where overflow checking is
turned on/off based on VERxxx defines and that you did not include the
VER210 yet?

-- 
Pieter

'That seems to point up a significant difference between Europeans
 and Americans. A European says: "I can't understand this, 
 what's wrong with me?" An American says: "I can't understand 
 this, what's wrong with him?"' -- Terry Pratchett
0
Pieter
2/2/2010 10:40:38 PM
Hello Pieter,

>> Could it be correct that there's a bug in Delphi7 where the compiler
>> directive {$Q-} and {$Q+} works completely the opposite?
>
> Assuming D7 build 8.1, not very likely.

Yes, that build.

>> When trying to build an existing Delhi 7 project in Delphi 2010 i
>> found this weird behaviour.  In D7 {$Q-} set overflow cheking on and
>> in Delphi 2010 off ?????
>
> Could it be that you use include files where overflow checking is
> turned on/off based on VERxxx defines and that you did not include the
> VER210 yet?

I can very easy reproduce this.
Simple make a new application in Delphi 7.
Drop a button on the form, double click and enter this code there:

procedure TForm1.Button1Click(Sender: TObject);
var
  lTotal, lIndex: Integer;
begin
{$OVERFLOWCHECKS OFF}
  lTotal := 0;
  for lIndex := 1 to 20 do
  begin
    lTotal := (131 * lTotal) + 97;
  end;
  lTotal := Abs(lTotal);
{$OVERFLOWCHECKS ON}
end;


Save the project and run the application in Delphi 7, i get an overflow error.

Reopen the application in Delphi 2010 and no overflow error.


Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database with many powerful SQL features:
  http://www.firebirdsql.org
  http://www.firebirdsql.info

General database developer support:
  http://www.databasedevelopmentforum.com

Support list for Interbase and Firebird users:
  firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
  news://newsgroups.firebirdsql.info
0
Arno
2/9/2010 10:54:38 AM
"Arno Brinkman" wrote:
> I can very easy reproduce this.
> Simple make a new application in Delphi 7.
> Drop a button on the form, double click and enter this code there:
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>  lTotal, lIndex: Integer;
> begin
> {$OVERFLOWCHECKS OFF}
>  lTotal := 0;
>  for lIndex := 1 to 20 do
>  begin
>    lTotal := (131 * lTotal) + 97;
>  end;
>  lTotal := Abs(lTotal);
> {$OVERFLOWCHECKS ON}
> end;
>
>
> Save the project and run the application in Delphi 7, i get an 
> overflow error.
>
> Reopen the application in Delphi 2010 and no overflow error.

Arno,

I can confirm that Q+ and Q- are inverted in operation also in D2005.
Looking at the disassembly, there are JNO:s in the Q- state and not in 
the Q+ state.

Regards
Tom
0
Tom
2/9/2010 11:34:58 AM
Arno Brinkman wrote:

> > Assuming D7 build 8.1, not very likely.
> 
> Yes, that build.
> 
> > > When trying to build an existing Delhi 7 project in Delphi 2010 i
> > > found this weird behaviour.  In D7 {$Q-} set overflow cheking on
> > > and in Delphi 2010 off ?????
> > 
> > Could it be that you use include files where overflow checking is
> > turned on/off based on VERxxx defines and that you did not include
> > the VER210 yet?
> 
> I can very easy reproduce this.
> Simple make a new application in Delphi 7.
> Drop a button on the form, double click and enter this code there:
> 
> procedure TForm1.Button1Click(Sender: TObject);
> var
>  lTotal, lIndex: Integer;
> begin
> {$OVERFLOWCHECKS OFF}
>  lTotal := 0;
>  for lIndex := 1 to 20 do
>  begin
>    lTotal := (131 * lTotal) + 97;
>  end;
>  lTotal := Abs(lTotal);
> {$OVERFLOWCHECKS ON}
> end;
> 
> 
> Save the project and run the application in Delphi 7, i get an
> overflow error.

Indeed strange when you use them inside a method the effect seems to be
reversed. Moving them outside the method should work OK.

> Reopen the application in Delphi 2010 and no overflow error.

So whatever the cause was, it looks like this is fixed in the later
versions.

-- 
Pieter

"Let's not bring age into this discussion. I will not let 
 my opponent's youth and inexperience become an issue."
 -- Ronald Reagan on Walter Mondale
...
0
Pieter
2/10/2010 10:09:56 PM
Hi,

>> Save the project and run the application in Delphi 7, i get an
>> overflow error.
>
> Indeed strange when you use them inside a method the effect seems to be
> reversed. Moving them outside the method should work OK.
>
>> Reopen the application in Delphi 2010 and no overflow error.
>
> So whatever the cause was, it looks like this is fixed in the later
> versions.

Yes, but because we share code between projects we need to solve it by IFDEFs VERxxx.

Something for in the "notes or gotchas when converting to D2010" list :-)

Result can be worser then you think, cause when you expect error when an overflow happens, it doesn't happen...

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database with many powerful SQL features:
  http://www.firebirdsql.org
  http://www.firebirdsql.info

General database developer support:
  http://www.databasedevelopmentforum.com

Support list for Interbase and Firebird users:
  firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
  news://newsgroups.firebirdsql.info
0
Arno
2/11/2010 2:04:48 PM
Reply:

Web resources about - Delphi 7 versus Delphi 2010 compiler directive {$Q-} - embarcadero.delphi.ide

Directive (European Union) - Wikipedia, the free encyclopedia
Article 288 To exercise the Union's competences, the institutions shall adopt regulations, directives, decisions, recommendations and opinions. ...

Federal directive on solar threatens commercial rooftop projects in the ACT, says Simon Corbell
Tony Abbott is public enemy No 1 on renewable energy says Simon Corbell. The Abbott government's directive against investment in small and medium-scale ...

Bali 9 executions: Abbott government backflipped on AFP death penalty directive
The Abbott government quietly scrapped an instruction to the Australian Federal Police last year requiring it to take Australia's opposition ...

Liberal MP Sarah Henderson puts pressure on Government to reverse directive on wind, solar investment ...
The Government faces internal pressure to reverse its push to stop the Clean Energy Finance Corporation from investing in wind farms and household ...

Directive Games shaking up core mobile - Pocket Gamer.biz - PGbiz
The road to finding hardcore gamers on mobile is - as yet - strewn with failures. But that doesn't mean more start-ups aren't attempting to reach ...

TEXAS: Gov. Greg Abbott Issues "Religious Liberty" Directive To Protect Anti-Gay State Staffers From ...
Via Talking Points Memo : Following the ruling, Texas Gov. Greg Abbott (R) issued a directive on Friday ordering state agencies to "prioritize ...

Trekonomics Teaser Clip: The Prime Directive...
... Economics at UC Berkeley and former Deputy Assistant Secretary at the US Treasury. Inkshares' Adam Gomolin is the moderator: [The prime dir ...

EU officials set sights on new drone directive
EU officials want to set up a legal framework to govern the use of drones, amid safety and security concerns. The European Commission is collecting ...

NGA prepares directive to speed acquisition
NGA Deputy Director Susan Gordon says coming guidance will put tangible policy behind the agency’s oft-stated goal of more quickly deploying ...

Northwestern MutualVoice: What You Should Know About Advance Directives
... happened and they couldn’t make their own health care decisions. Yet only about a third of Americans age 18 or older have signed advance directives ...

Resources last updated: 1/8/2016 4:28:18 AM