Re: VC2008 Bug: optimising static_cast to a virtual base gives C1001 internal compile error



Victor Bazarov wrote:
Carl Daniel [VC++ MVP] wrote:
What if you turn off whole-program optimization, which is on by
default in release builds under 2005 and later?

I tried on 2008 EE, it didn't make a difference. The code that
causes is even simpler:

struct B {};
struct A : virtual B {};

int main()
{
B* b = reinterpret_cast<A*>(0);
}

(no precompiled headers, not "_t" stuff, no unneeded 'return'), and
it ICEs while _compiling_, not after the linker is done with it.

That's a pretty darn simple repro case.

I was able to repro it on 2008 Team Edition. Compiling with any combination
of -Oy -Oi -Ob -Os -Ot works fine, but including -Og, -O1 or -O2 causes the
ICE.

If this is an issue in real code, adding #pragma optimize("g",off) before
and #pragma optimize("g",on) after the function containing the
reinterpret_cast could be a usable workaround.

Has anyone opened a bug report on Connect?

-cd


.



Relevant Pages

  • Re: VC2008 Bug: optimising static_cast to a virtual base gives C1001 internal compile error
    ... it ICEs while _compiling_, not after the linker is done with it. ... I was able to repro it on 2008 Team Edition. ... If this is an issue in real code, adding #pragma optimizebefore ...
    (microsoft.public.vc.language)
  • Re: byte alignment/dynamic memory from heap x64
    ... I had seen the definition in the WDK header that uses ... declspec) and I was compiling with x64 compiler. ... struct and when my driver is loaded I dynamically allocate memory using these ... The documention for x64 states that SLIST_ENTRY and SLIST_HEADER must be 16 ...
    (microsoft.public.development.device.drivers)
  • Re: Packed structs vs. unpacked structs: whats the difference?
    ... The packed keyword ... Pragma pack is not often used to save space. ... packet) into a struct. ... This way you can access data within the packet ...
    (comp.lang.c)
  • Re: Problem passing structs to dlls
    ... I tryed your hint, using #pragma pack and got in BOTH, the native and ... It is as if the struct would be cleaned up by the gc if the dll-function ... Then this 815 is visible in the dll. ...
    (microsoft.public.dotnet.languages.vc)
  • pragma pack problems
    ... I seem to be running into an issue where I am deriving a new class from a struct with a different alignemnt via the pragma pack, I get a data abort error in the debugger. ... class CDerived: public MyBase ...
    (microsoft.public.windowsce.embedded.vc)

Loading