JDK-8041620 : Solaris Studio 12.4 C++ 5.13 change in behavior for placing friend declarations within surrounding scope
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-04-23
  • Updated: 2020-02-18
  • Resolved: 2014-05-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u241Fixed 9 b14Fixed openjdk8u252Fixed
Description
From: http://docs.oracle.com/cd/E37069_01/html/E37075/gnyjb.html#OSSCPgnyly

"When a friend declaration in class C for a function or class T was the first declaration of T, previous compilers incorrectly inserted the declaration of T into the surrounding scope. The Oracle Solaris Studio 12.4 C++ 5.13 compiler no longer does so, because it can lead to incorrect interpretation of valid programs."

An example of this change in behavior for Hotspot first shows up as an C++ error diagnostic in src/share/vm/adlc/filebuff.hpp

"<directory>/src/share/vm/adlc/filebuff.hpp", line 107: Error: Unqualified name '<<' in friend declaration is looked up in the nearest enclosing namespace and does not refer to existing '::std::operator<<<_charT, _Traits>(basic_ostream<_charT, _Traits>&, _charT)'.
1 Error(s) detected.

All friend declarations will have to be examined and potentially changed before using Solaris C++ 5.13.
Comments
Fix Request (8u) No risk (removes an unused C++ class), patch applies cleanly. This patch has been backported to Oracle 8u241 presumably to enable compilation with a newer compiler, but it's not a critical fix, so I've tagged it jdk8u-fix-request.
17-12-2019

As a side note, FileBuffRegion in filebuff.hpp is unused and can be removed.
28-04-2014

For clarification, the above C++ 5.13 diagnostic is actually a warning message that is bumped up to error level by the Hotspot makefiles.
23-04-2014