Skip to content

Commit a354701

Browse files
ihb2032meta-codesync[bot]
authored andcommitted
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: 3a93ac95efd90ed733041eff0f051a620db7f025
1 parent d34d8b0 commit a354701

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • third-party/folly/src/folly/container/detail

third-party/folly/src/folly/container/detail/F14Table.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,19 +814,19 @@ struct alignas(kRequiredVectorAlignment) F14Chunk {
814814
#endif
815815

816816
DenseMaskIter occupiedIter() const {
817-
return DenseMaskIter{&tags_[0], occupiedMask()};
817+
return DenseMaskIter{&tags_[0], this->occupiedMask()};
818818
}
819819

820820
MaskRangeIter occupiedRangeIter() const {
821-
return MaskRangeIter{occupiedMask()};
821+
return MaskRangeIter{this->occupiedMask()};
822822
}
823823

824824
LastOccupiedInMask lastOccupied() const {
825-
return LastOccupiedInMask{occupiedMask()};
825+
return LastOccupiedInMask{this->occupiedMask()};
826826
}
827827

828828
FirstEmptyInMask firstEmpty() const {
829-
return FirstEmptyInMask{occupiedMask() ^ kFullMask};
829+
return FirstEmptyInMask{this->occupiedMask() ^ kFullMask};
830830
}
831831

832832
bool occupied(std::size_t index) const {

0 commit comments

Comments
 (0)