\Og instead of \O2

G

Guest

Hi,

I am porting a Visual Studio 6 project to Visual Studio 2005 and am in the
process of determining which optimisation flags to use.

The project builds a server - so "Maximize speed" is the best option.
However this option appears to have a few unpleasant side effects namely
implicitly setting /Oy (frame pointer optimisation) and "Named Return Value
Optimisation" both of which appear to break parts of the server.

After some trial and error and I seem to be able to get what I want setting
"/Og /Oi /Ot /Ob2 /Gs /GF /Gy" i.e. avoiding the \Oy.

However I have teh following questions:

1. /Od is reported as being deprecated. Howver I appear to need to set it to
get optimsiations. /O1, /O2 and /Ox all set /Oy implicitly. Is there a
non-deparecated way of acheiving this?

2. There appears to be no way of switching on or off NRVO other than by /O1,
/O2 or /Ox. Is this the case?

3. 2. implies that /O2 is doing more than teh stated equivialent - what
else does it do?

Simon
 
T

Tom Widmer [VC++ MVP]

Simon said:
Hi,

I am porting a Visual Studio 6 project to Visual Studio 2005 and am in the
process of determining which optimisation flags to use.

The project builds a server - so "Maximize speed" is the best option.
However this option appears to have a few unpleasant side effects namely
implicitly setting /Oy (frame pointer optimisation) and "Named Return Value
Optimisation" both of which appear to break parts of the server.

You can use /Oy– to help with the former, though I don't see a way to
disable the latter. Have you read about the O options in MSDN
(http://msdn2.microsoft.com/en-us/library/k1ack8f1.aspx)?
After some trial and error and I seem to be able to get what I want setting
"/Og /Oi /Ot /Ob2 /Gs /GF /Gy" i.e. avoiding the \Oy.

However I have teh following questions:

1. /Od is reported as being deprecated. Howver I appear to need to set it to
get optimsiations. /O1, /O2 and /Ox all set /Oy implicitly. Is there a
non-deparecated way of acheiving this?

/Od disables optimization!
2. There appears to be no way of switching on or off NRVO other than by /O1,
/O2 or /Ox. Is this the case?

As far as I can tell, yes.
3. 2. implies that /O2 is doing more than teh stated equivialent - what
else does it do?

Pass.

As a general comment, you might consider finding the points of undefined
behaviour in your code that have been exposed by the new compiler and
fixing them - otherwise it is difficult to be confident that your server
will work.

Tom
 
G

Guest

Sorry, user error. I meant to say /Og is deprecated. Is there a
non-depreceated way of setting the same options that do not involve /O1 or
/O2?

Alas I cannot "fixed the code" as the bits of code that appear to have
issues with NRVO are in a 3rd party DLL. Not my code.

I need to disable /Oy so that a custom exception handler works.

Simon
 
T

Tom Widmer [VC++ MVP]

Simon said:
Sorry, user error. I meant to say /Og is deprecated. Is there a
non-depreceated way of setting the same options that do not involve /O1 or
/O2?

/Og enables NRVO in any case, so you can't use it from what you've said
(http://msdn2.microsoft.com/en-us/library/1yk3ydd7.aspx)
Alas I cannot "fixed the code" as the bits of code that appear to have
issues with NRVO are in a 3rd party DLL. Not my code.

Well, you must have the source code or you wouldn't be compiling it and
wouldn't have a problem, so in theory you could fix it, couldn't you? Or
pester the authors to do so?
I need to disable /Oy so that a custom exception handler works.

As far as I can tell, the options you already have, minus /Og, is about
the best you can do. If you fix the 3rd party dll, you can use
"/02 /Oy-" - it's NRVO that's your main problem, since /Og unavoidably
enables it.

Tom
 
Top