<<< Date Index >>>     <<< Thread Index >>>

Re: Bug in Sun studio 11



> >>>Wow, that's voodoo. I don't see any harm in making the change though.
> >>
> >>Making the variable static makes compiler to store the value to physical 
> >>memory and not just to register. I can confirm that on SS12 the problem
> >
> >you'd think &mycrc would have the same effect :)
> 
> It *should*, but I guess that's the very definition of a bug, eh? :)

:)


> >>no longer exists. But at the same time, SS11 may not be fixed, 
> >>since it is not priority anymore ...
> >
> >I'll probably apply it. I'm just giving it time to see if any other C 
> >gurus comment.
> 
> Well... there's the obvious comment, which is that if you're relying 
> on mycrc being initialized to zero in the function, making it static 
> will break that, so you'd need to add a separate mycrc=0; line in 
> after it is declared, because the existing initialization won't take 
> care of that.

Correct, although it does not matter in this case, as mycrc is filled by
restore_int.


> The other problem with making it static is that it prevents the 
> compiler from doing certain kinds of optimization. That's not a 
> performance-critical function, but...

Unmeasurable.


> I'd be somewhat uncomfortable with adding goofy-looking code to work
> around compiler bugs---especially when the bug has been fixed in the
> current version of the compiler. I mean, we aren't still working
> around gcc 1.0 bugs, why work around SS11 bugs?

Agreed. SS12 is out one month, thought ...



> If anything, put it in
> an #ifdef, such as:
> 
>     #ifdef __SUN11__ /* or whatever signifies that compiler */
>     static int mycrc;
>     mycrc = 0;
>     #else
>     int mycrc = 0;
>     #endif

Why not, if you believe that it's worth of six lines instead of one.
Anything which will potentially stop others seeing the issue. I can't
force the C team so I'm trying my luck here :) I'll forge the correct
version and post it here.

Thanks for the comments
-- 
        Vlad