Skip to content

CodeQL C++ Extractor — GCC 12.2.0 + Recent LLVM libc++ Extraction Failures #22514

Description

@ANegm-ETAS

Summary

The CodeQL C++ extractor (v2.26.0, --mimic mode, --gnu_version 120200) produces parse errors in nearly all translation units when processing a codebase compiled with GCC 12.2.0 paired with a recent LLVM libc++ standard library. The C++ compiler is q++ (QNX SDP 8.0.0), which combines a GCC 12.2.0 frontend with LLVM libc++ headers. All errors are in libc++ system headers (std::__2:: namespace) with no errors in user code. The real q++ compiler compiles every translation unit without issue.

Switching the same codebase to libstdc++ (with the same GCC 12.2.0 version) eliminates all errors.

Environment

Component Version
CodeQL CLI / extractor 2.26.0
C++ compiler q++ from QNX SDP 8.0.0 (GCC 12.2.0 frontend + LLVM libc++)
Standard library LLVM libc++ (namespace std::__2)
Host / target Linux x86_64

Symptoms

Errors span multiple libc++ headers and all follow the same pattern: the extractor's internal C++ frontend fails template deduction or SFINAE substitution where GCC 12.2.0 succeeds. Examples:

error: class "std::__2::iterator_traits<std::__2::__wrap_iter<char *>>"
  has no member "iterator_category"

error: no instance of overloaded function "std::__2::__search_impl"
  matches the argument list
candidate function template failed deduction

error: no instance of constructor
  "std::__2::pair<_T1, _T2>::pair [...]" matches the argument list

Reproduction

The real compiler succeeds; the extractor fails:

EXTRACTOR="$CODEQL_BUNDLE/cpp/tools/linux64/extractor"
COMPILER="/path/to/gcc-12.2.0-based-compiler"

cat > test.cpp << 'EOF'
#include <algorithm>
#include <vector>
#include <string>
void f() {
    std::vector<char> v(10);
    std::fill(v.begin(), v.end(), 0);
    std::string s(10, ' ');
    std::fill(s.begin(), s.end(), 'x');
}
EOF

"$COMPILER" -std=c++17 -c test.cpp -o /dev/null       # exit 0
"$EXTRACTOR" --mimic "$COMPILER" --object_filename /dev/null \
  --error_limit 1000 -std=c++17 -c test.cpp -o /dev/null 2>&1 | grep "error:"

Root Cause

The extractor's internal C++ frontend does not fully replicate GCC 12.2.0's template deduction and SFINAE substitution behavior when processing recent LLVM libc++ headers. This manifests across multiple libc++ internals — iterator traits (__wrap_iter), algorithm SFINAE guards (__enable_if_t), and conditional constructors (pair, optional) — but the underlying cause is the same: the extractor frontend reaches different SFINAE outcomes than GCC 12.2.0.

What works

  • GCC 12.2.0 + libstdc++: 0 extraction errors
  • GCC 11.4 + LLVM 14 libc++: 0 extraction errors (older libc++, different SFINAE patterns)

codeql-extraction-logs.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions