Commit a354701
Fix: Resolve compilation failure in F14Table.h due to two-phase lookup
Summary:
Hi, this PR fixes a compilation issue in `folly/container/detail/F14Table.h`.
### Bug Description
When building Folly with a modern g++ toolchain, the compilation fails with multiple errors related to `occupiedMask`.
**Environment:**
* **OS:** Ubuntu 24.04
* **g++ version:** 13.3.0
* **CPU:** Intel(R) Xeon(R) E-2286M CPU @ 2.40GHz
**Key Error Message:**
```
/root/folly/folly/container/detail/F14Table.h:821:37: error: there are no arguments to 'occupiedMask' that depend on a template parameter, so a declaration of 'occupiedMask' must be available [-fpermissive]
821 | return DenseMaskIter{&tags_[0], occupiedMask()};
| ^~~~~~~~~~~~
```
### Root Cause
The error is a classic C++ two-phase name lookup problem. Inside the `F14Chunk<ItemType>` template, functions like `occupiedIter()` call `occupiedMask()` without any qualification. Because `occupiedMask` is a member function of `F14Chunk`, its existence depends on the template parameter `ItemType`. According to the rules, the compiler needs to be explicitly told that `occupiedMask` is a dependent name, which g++ 13.3.0 correctly enforces.
### The Fix
The solution is to explicitly qualify the calls to `occupiedMask` with `this->`. This informs the compiler that `occupiedMask` is a member of the template instance and its lookup should be deferred to the instantiation phase.
This change is applied to all calls to `occupiedMask` within `F14Chunk` in `folly/container/detail/F14Table.h`.
### How to Test
The fix can be verified by successfully compiling the `folly_base` target in the described environment (Ubuntu 24.04, g++ 13.3.0) where the build was previously failing. All existing tests should continue to pass.
Thanks for your review\!During compilation with certain toolchains (e.g., g++), the build fails with an "'occupiedMask' was not declared in this scope" error inside the F14Chunk template class.
This is caused by C++'s two-phase name lookup rules for templates, where non-dependent names are resolved during the initial template parsing. The compiler fails to find 'occupiedMask' as it is a member of a dependent base class.
This commit resolves the build failure by explicitly qualifying the member function calls with 'this->', correctly hinting to the compiler that 'occupiedMask' is a dependent name that should be looked up during template instantiation.
X-link: facebook/folly#2491
Reviewed By: dmm-fb
Differential Revision: D93942306
Pulled By: yfeldblum
fbshipit-source-id: 3a93ac95efd90ed733041eff0f051a620db7f0251 parent d34d8b0 commit a354701
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
821 | | - | |
| 821 | + | |
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
| 825 | + | |
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
| 829 | + | |
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
| |||
0 commit comments