IListStream scope issue with Foam::List
Summary
Scope issue with List in IListStream.H
.
Whilst testing a new compiler release we encountered a build issue with IListStream.H
, line 161.
The use of List<char>&& buffer,
tries to inherit List<char>
from Detail::IListStreamAllocator
. However, this is a private member, and so can not be used. I believe the correct usage should be of Foam::list
.
I have raised this with our internal compiler team, and they believe this to be a code issue rather than a compiler issue.
I believe this relates the the issue shown https://stackoverflow.com/questions/41595208/accessing-the-name-of-a-private-inherited-class-from-a-subclass
Steps to reproduce
This issue was encountered when building OpenFOAM 1906 with the Arm Compiler for Linux 20.0 (LLVM 9 based). So I believe this to be an issue for Clang 9. Simply building with the new compiler 20.0 encountered this issue - as LLVM 9 is being stricter. This was not an issue with the previous version 19.3 (LLVM 7 based) - nor GCC.
Example case
I have reduced the relevant files to the included MWE. List_20.0.tar.gz
> clang++ -std=c++11 -mcpu=native -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O3 -I. -fPIC -c reproducer.C
In file included from reproducer.C:1:
./IListStream.H:103:10: error: 'List' is a private member of 'Foam::List<char>'
List<char>&& buffer
^
./IListStream.H:61:5: note: constrained by private inheritance here
private List<char>
^~~~~~~~~~~~~~~~~~
./List.H:65:7: note: member is declared here
class List
^
1 error generated.
What is the current bug behaviour?
As shown above, the attempt is made to scope List<char>
from the wrong source - IListStreamAllocator
.
What is the expected correct behavior?
List<char>
should be sourced from List.H
.
Relevant logs and/or images
Environment information
- OpenFOAM version : v1906
- Operating system : RHEL 7 + 8
- Hardware info : Arm (aarch64)
- Compiler : clang 9 (armclang from Arm Compiler for Linux 20.0)
Possible fixes
Before:
List<char>&& buffer,
After:
Foam::List<char>&& buffer,