RFR(XXS): 8132232: Signature mismatch between declaration and definition of PosixSemaphore::timedwait

Kim Barrett kim.barrett at oracle.com
Sat Jul 25 03:03:03 UTC 2015

On Jul 24, 2015, at 3:05 AM, Volker Simonis <volker.simonis at gmail.com> wrote:
> Hi David,
> thanks for looking into this issue.
> Just to clarify: according to the standard this const has no effect at
> all and should be ignored by the compiler (i.e. foo(int) and foo(const
> int) is the same). I just want to adjust the two occurrences in the
> declaration and the definition (preferably by removing const because
> it doesn't has any effect anyway) to work around a compiler bug AND
> for code style reasons to prevent further ambiguities.

For the record, that isn’t exactly true.

In a declaration, foo(T) and foo(const T) are the same (for T not a reference or pointer type).

In a definition, they aren’t the same.  Specifically, a const qualifier in a definition prevents modification of the value in the function body.

So it's perfectly sensible to have foo(T) in the declaration and foo(const T) in the (separate) definition, though perhaps uncommon.

The complaint about the mismatch is clearly a compiler bug, which empirically appears to have been fixed in a later patch release.  Hence my “Ick!” in response to this change.  Since it didn’t really hurt anything to remove the const in the definition (there aren’t any modifications of that value and the function is tiny and easily understood), I was ok with the workaround, rather than arguing that Volker should update his compiler (which we all know can be far more work than one would think it ought to be).

More information about the hotspot-dev mailing list