RFR (XL) 8046070 - Class Data Sharing clean up and refactoring, round #2

Kim Barrett kim.barrett at oracle.com
Fri Aug 8 06:59:10 UTC 2014


On Aug 3, 2014, at 2:59 AM, Ioi Lam <ioi.lam at oracle.com> wrote:
> 
> David, thanks for the comments. I will fix the code as you suggested.
> 
>> 225   int index = 0; // Defined here for portability! Do not move
>> 
>> ??? Do we have a C compiler that can't declare loop variables?
> I probably had two loops using the "index" variable. I remember some old C++ compilers would be confused if you do
> 
>    for (int index=0; ...) {}
> for (int index=0; ...) {}
> 
> and would complain that "index" was declared twice. In any case, I will remove the comment here and move the declaration of "index" into the "for" statement.

gcc has had -ffor-scope for a *very* long time; I found it mentioned in docs for g++ 2.95.

-ffor-scope
-fno-for-scope
If -ffor-scope is specified, the scope of variables declared in a for-init-statement is limited to the ‘for’ loop itself, as specified by the C++ standard. If -fno-for-scope is specified, the scope of variables declared in a for-init-statement extends to the end of the enclosing scope, as was the case in old versions of G++, and other (traditional) implementations of C++.
If neither flag is given, the default is to follow the standard, but to allow and give a warning for old-style code that would otherwise be invalid, or have different behavior.

I have no knowledge of other compilers’ conformance (or lack thereof) to c++98 for-loop scoping rules.



More information about the hotspot-runtime-dev mailing list