codeql icon indicating copy to clipboard operation
codeql copied to clipboard

C++: request for support more C++ features to avoid failures in CodeQL compile

Open qwerty472123 opened this issue 1 year ago • 7 comments
trafficstars

Support these can make developer analyzing projects easiler, which not require to change the lots of projects code rely on these.

  1. -Wno-c++11-narrowing and -Wno-narrowing

There are some projects use these flags, and extractor support --diag_suppress narrowing_conversion, too. However, the conversion between the --mimic format of commandline to processed commandline won't translate -Wno-narrowing into --diag_suppress narrowing_conversion.

And there is no option to set -Wno-c++11-narrowing without downgrading the c++ standard version or changing source code to compile.

  1. the marco __FILE_NAME__

This is a non-standard marco but clang and gcc support and some projects use them.

  1. arm_neon.h

Some cross-compile projects will raise errors in these functions.

qwerty472123 avatar Jun 03 '24 11:06 qwerty472123

Hi @qwerty472123,

Thanks for raising this issue.

  1. Silencing warnings is in general immaterial, unless they cause extractor errors when not silenced. If you see extractor errors, could you please open a new issue that explains how to reproduce the error?
  2. This indeed seems an omission.
  3. We currently do not fully support ARM targets in cross-complies, so this is expected. I've added this issue to our internal tracking issue for this.

jketema avatar Jun 03 '24 12:06 jketema

Hi @jketema,

Thanks for your kindly reply.

  1. Although warnings usually do not affect compilation, these two warnings(c++11-narrowing and narrowing) are regarded as errors by default, which causes the extractor to output error and return non-zero values, here is an example:
enum class CompilerName : unsigned char {
    INVALID = -1, // Warning as Error by default
    Clang = 0,
    MSVC = 1,
};
struct Obj { unsigned int value; };
int main() {
    unsigned long long v=1llu;
    struct Obj obj = { .value = v }; // This is OK
    obj = { .value = v }; // Warning as Error by default
}

which let clang++ -Wno-c++11-narrowing -Wno-narrowing -c test.cpp -o test.o shows nothing(success to compile), but let /usr/local/bin/codeql/cpp/tools/linux64/extractor --mimic $(which clang++) -Wno-c++11-narrowing -Wno-narrowing -c test.cpp -o test.o outputs:

...
"test.cpp", line 2: error: enumeration value is outside the range of its underlying type ("unsigned char")
      INVALID = -1, // Warning as Error by default
                ^

[E 02:05:00 145891] Warning[extractor-c++]: In construct_text_message: "test.cpp", line 2:
 error: enumeration value is outside the range of its underlying type ("unsigned char")
      INVALID = -1, // Warning as Error by default
                ^


"test.cpp", line 10: error: invalid narrowing conversion from "unsigned long long" to "unsigned int"
      obj = { .value = v }; // Warning as Error by default
                       ^

[E 02:05:00 145891] Warning[extractor-c++]: In construct_text_message: "test.cpp", line 10: error: invalid narrowing conversion from "unsigned long long" to "unsigned int"
      obj = { .value = v }; // Warning as Error by default
                       ^
...
[E 02:05:00 145891] Warning[extractor-c++]: In main: Extractor exiting with code 1
  1. And here is another two differences between clang and CodeQL extractor(though these two cases are rarely), this is a demo code:
int main() {
  char *ptr = new char[]{ "str" };
  int value = 0;
  int * _Nonnull ptr_nonnull = &value;
  int * _Nonnull * ptr_to_nonnull = &ptr_nonnull;
  int **simple_ptr = ptr_to_nonnull;
}

which let clang++ -c test.cpp -o test.o shows nothing(success to compile), but let /usr/local/bin/codeql/cpp/tools/linux64/extractor --mimic $(which clang++) -c test.cpp -o test.o outputs:

...
"test.cpp", line 2: error: incomplete type "char []" is not allowed
    char *ptr = new char[]{ "str" };
                    ^

[E 02:11:29 145917] Warning[extractor-c++]: In construct_text_message: "test.cpp", line 2:
 error: incomplete type "char []" is not allowed
    char *ptr = new char[]{ "str" };
                    ^


"test.cpp", line 6: error: a value of type "int *_Nonnull *" cannot be used to initialize an entity of type "int **"
    int **simple_ptr = ptr_to_nonnull;
                       ^

[E 02:11:29 145917] Warning[extractor-c++]: In construct_text_message: "test.cpp", line 6: error: a value of type "int *_Nonnull *" cannot be used to initialize an entity of type "int **"
    int **simple_ptr = ptr_to_nonnull;
                       ^
...
[E 02:11:29 145917] Warning[extractor-c++]: In main: Extractor exiting with code 1

Clang can deduce the array length from the construction parameters and thinks that the conversion from int * _Nonnull * to int * * is feasible. However, CodeQL extractor only thinks that the conversion from int * _Nonnull to int * is feasible.

qwerty472123 avatar Jun 04 '24 02:06 qwerty472123

Hi @qwerty472123

The narrowing issues should no longer occur in CodeQL 2.17.5, which should be released within the next few weeks. Note that even though the extractor produced an error here, the database was still complete.

jketema avatar Jun 07 '24 08:06 jketema

I've reported the __FILE_NAME__ and _Nonnull issues to our frontend provider.

The char *ptr = new char[]{ "str" }; problem I cannot reproduce. Can you provide me with:

  • The version of CodeQL you're using
  • The version of clang you're using
  • The full output of the extractor for extractor --mimic $(which clang++) -c test.cpp -o test.o, where test.cpp contains:
    int main() {
      char *ptr = new char[]{ "str" };
      return 0;
    }   
    

jketema avatar Jun 07 '24 08:06 jketema

Hi @jketema

Thanks for your quickly fix.

For the char *ptr = new char[]{ "str" }; problem:

  • The version of CodeQL: founded in 2.17.3, 2.17.4 is also have the error output

  • The version of clang: 15.0.7 from apt(ubuntu 22.04)

  • The full output:

$ cat test.cpp
int main() {
  char *ptr = new char[]{ "str" };
  return 0;
}
$ $(which clang++) -c test.cpp -o test.o
$ /usr/local/bin/codeql/cpp/tools/linux64/extractor --mimic $(which clang++) -c test.cpp -o test.o
[E 15:50:46 4121111] CodeQL C/C++ Extractor 2.17.4
[E 15:50:46 4121111] CODEQL_EXTRACTOR_CPP_SCRATCH_DIR does not exist; not saving separate log file.
[E 15:50:46 4121111] Could not open log file; not saving separate log file.
[E 15:50:46 4121111] Current directory: /tmp/codeqltest
[E 15:50:46 4121111] Command: /usr/local/bin/codeql/cpp/tools/linux64/extractor --mimic '/usr/bin/clang++' -c test.cpp -o test.o
Warning: Could not open file './compiler_mimic_cache/0cbdb51a1492'
[E 15:50:46 4121111] Checking whether C compilation already happened.
[E 15:50:46 4121111] Checking for tag c-compilation-happened
[E 15:50:46 4121111] Looks like C compilation didn't already happen.
[E 15:50:46 4121111] Checking whether C compilation has been attempted.
[E 15:50:46 4121111] Checking for tag c-compilation-attempted
[E 15:50:46 4121111] Marking C compilation as attempted.
[E 15:50:46 4121111] Setting tag c-compilation-attempted
[E 15:50:46 4121111] Processed command line: /usr/local/bin/codeql/cpp/tools/linux64/extractor --object_filename test.o -w --error_limit 1000 --disable_system_macros --variadic_macros --incognito '--g++' --clang_version 150007 --gnu_version 40801 --has_feature_vector 1111111100000011011111110111111111111111111011111111111110111111111111 --clang --target linux_x86_64 -D_GNU_SOURCE=1 -D_LP64=1 -D__ATOMIC_ACQUIRE=2 -D__ATOMIC_ACQ_REL=4 -D__ATOMIC_CONSUME=1 -D__ATOMIC_RELAXED=0 -D__ATOMIC_RELEASE=3 -D__ATOMIC_SEQ_CST=5 -D__BIGGEST_ALIGNMENT__=16 -D__BITINT_MAXWIDTH__=128 -D__BOOL_WIDTH__=8 -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__ -D__CHAR_BIT__=8 -D__CLANG_ATOMIC_BOOL_LOCK_FREE=2 -D__CLANG_ATOMIC_CHAR16_T_LOCK_FREE=2 -D__CLANG_ATOMIC_CHAR32_T_LOCK_FREE=2 -D__CLANG_ATOMIC_CHAR_LOCK_FREE=2 -D__CLANG_ATOMIC_INT_LOCK_FREE=2 -D__CLANG_ATOMIC_LLONG_LOCK_FREE=2 -D__CLANG_ATOMIC_LONG_LOCK_FREE=2 -D__CLANG_ATOMIC_POINTER_LOCK_FREE=2 -D__CLANG_ATOMIC_SHORT_LOCK_FREE=2 -D__CLANG_ATOMIC_WCHAR_T_LOCK_FREE=2 -D__CONSTANT_CFSTRINGS__=1 -D__DBL_DECIMAL_DIG__=17 -D__DBL_DENORM_MIN__=4.9406564584124654e-324 -D__DBL_DIG__=15 -D__DBL_EPSILON__=2.2204460492503131e-16 -D__DBL_HAS_DENORM__=1 -D__DBL_HAS_INFINITY__=1 -D__DBL_HAS_QUIET_NAN__=1 -D__DBL_MANT_DIG__=53 -D__DBL_MAX_10_EXP__=308 -D__DBL_MAX_EXP__=1024 '-D__DBL_MAX__=1.7976931348623157e+308' '-D__DBL_MIN_10_EXP__=(-307)' '-D__DBL_MIN_EXP__=(-1021)' -D__DBL_MIN__=2.2250738585072014e-308 -D__DECIMAL_DIG__=__LDBL_DECIMAL_DIG__ -D__DEPRECATED=1 -D__ELF__=1 -D__EXCEPTIONS=1 -D__FINITE_MATH_ONLY__=0 -D__FLOAT128__=1 -D__FLT16_DECIMAL_DIG__=5 -D__FLT16_DENORM_MIN__=5.9604644775390625e-8F16 -D__FLT16_DIG__=3 -D__FLT16_EPSILON__=9.765625e-4F16 -D__FLT16_HAS_DENORM__=1 -D__FLT16_HAS_INFINITY__=1 -D__FLT16_HAS_QUIET_NAN__=1 -D__FLT16_MANT_DIG__=11 -D__FLT16_MAX_10_EXP__=4 -D__FLT16_MAX_EXP__=16 '-D__FLT16_MAX__=6.5504e+4F16' '-D__FLT16_MIN_10_EXP__=(-4)' '-D__FLT16_MIN_EXP__=(-13)' -D__FLT16_MIN__=6.103515625e-5F16 -D__FLT_DECIMAL_DIG__=9 -D__FLT_DENORM_MIN__=1.40129846e-45F -D__FLT_DIG__=6 -D__FLT_EPSILON__=1.19209290e-7F -D__FLT_HAS_DENORM__=1 -D__FLT_HAS_INFINITY__=1 -D__FLT_HAS_QUIET_NAN__=1 -D__FLT_MANT_DIG__=24 -D__FLT_MAX_10_EXP__=38 -D__FLT_MAX_EXP__=128 '-D__FLT_MAX__=3.40282347e+38F' '-D__FLT_MIN_10_EXP__=(-37)' '-D__FLT_MIN_EXP__=(-125)' -D__FLT_MIN__=1.17549435e-38F -D__FLT_RADIX__=2 -D__FXSR__=1 -D__GCC_ASM_FLAG_OUTPUTS__=1 -D__GCC_ATOMIC_BOOL_LOCK_FREE=2 -D__GCC_ATOMIC_CHAR16_T_LOCK_FREE=2 -D__GCC_ATOMIC_CHAR32_T_LOCK_FREE=2 -D__GCC_ATOMIC_CHAR_LOCK_FREE=2 -D__GCC_ATOMIC_INT_LOCK_FREE=2 -D__GCC_ATOMIC_LLONG_LOCK_FREE=2 -D__GCC_ATOMIC_LONG_LOCK_FREE=2 -D__GCC_ATOMIC_POINTER_LOCK_FREE=2 -D__GCC_ATOMIC_SHORT_LOCK_FREE=2 -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -D__GCC_ATOMIC_WCHAR_T_LOCK_FREE=2 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1 -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GNUC__=4 -D__GNUG__=4 -D__GXX_ABI_VERSION=1002 -D__GXX_EXPERIMENTAL_CXX0X__=1 -D__GXX_RTTI=1 -D__GXX_WEAK__=1 -D__INT16_C_SUFFIX__= '-D__INT16_FMTd__="hd"' '-D__INT16_FMTi__="hi"' -D__INT16_MAX__=32767 -D__INT16_TYPE__=short -D__INT32_C_SUFFIX__= '-D__INT32_FMTd__="d"' '-D__INT32_FMTi__="i"' -D__INT32_MAX__=2147483647 -D__INT32_TYPE__=int -D__INT64_C_SUFFIX__=L '-D__INT64_FMTd__="ld"' '-D__INT64_FMTi__="li"' -D__INT64_MAX__=9223372036854775807L '-D__INT64_TYPE__=long int' -D__INT8_C_SUFFIX__= '-D__INT8_FMTd__="hhd"' '-D__INT8_FMTi__="hhi"' -D__INT8_MAX__=127 '-D__INT8_TYPE__=signed char' -D__INTMAX_C_SUFFIX__=L '-D__INTMAX_FMTd__="ld"' '-D__INTMAX_FMTi__="li"' -D__INTMAX_MAX__=9223372036854775807L '-D__INTMAX_TYPE__=long int' -D__INTMAX_WIDTH__=64 '-D__INTPTR_FMTd__="ld"' '-D__INTPTR_FMTi__="li"' -D__INTPTR_MAX__=9223372036854775807L '-D__INTPTR_TYPE__=long int' -D__INTPTR_WIDTH__=64 '-D__INT_FAST16_FMTd__="hd"' '-D__INT_FAST16_FMTi__="hi"' -D__INT_FAST16_MAX__=32767 -D__INT_FAST16_TYPE__=short -D__INT_FAST16_WIDTH__=16 '-D__INT_FAST32_FMTd__="d"' '-D__INT_FAST32_FMTi__="i"' -D__INT_FAST32_MAX__=2147483647 -D__INT_FAST32_TYPE__=int -D__INT_FAST32_WIDTH__=32 '-D__INT_FAST64_FMTd__="ld"' '-D__INT_FAST64_FMTi__="li"' -D__INT_FAST64_MAX__=9223372036854775807L '-D__INT_FAST64_TYPE__=long int' -D__INT_FAST64_WIDTH__=64 '-D__INT_FAST8_FMTd__="hhd"' '-D__INT_FAST8_FMTi__="hhi"' -D__INT_FAST8_MAX__=127 '-D__INT_FAST8_TYPE__=signed char' -D__INT_FAST8_WIDTH__=8 '-D__INT_LEAST16_FMTd__="hd"' '-D__INT_LEAST16_FMTi__="hi"' -D__INT_LEAST16_MAX__=32767 -D__INT_LEAST16_TYPE__=short -D__INT_LEAST16_WIDTH__=16 '-D__INT_LEAST32_FMTd__="d"' '-D__INT_LEAST32_FMTi__="i"' -D__INT_LEAST32_MAX__=2147483647 -D__INT_LEAST32_TYPE__=int -D__INT_LEAST32_WIDTH__=32 '-D__INT_LEAST64_FMTd__="ld"' '-D__INT_LEAST64_FMTi__="li"' -D__INT_LEAST64_MAX__=9223372036854775807L '-D__INT_LEAST64_TYPE__=long int' -D__INT_LEAST64_WIDTH__=64 '-D__INT_LEAST8_FMTd__="hhd"' '-D__INT_LEAST8_FMTi__="hhi"' -D__INT_LEAST8_MAX__=127 '-D__INT_LEAST8_TYPE__=signed char' -D__INT_LEAST8_WIDTH__=8 -D__INT_MAX__=2147483647 -D__INT_WIDTH__=32 -D__LDBL_DECIMAL_DIG__=21 -D__LDBL_DENORM_MIN__=3.64519953188247460253e-4951L -D__LDBL_DIG__=18 -D__LDBL_EPSILON__=1.08420217248550443401e-19L -D__LDBL_HAS_DENORM__=1 -D__LDBL_HAS_INFINITY__=1 -D__LDBL_HAS_QUIET_NAN__=1 -D__LDBL_MANT_DIG__=64 -D__LDBL_MAX_10_EXP__=4932 -D__LDBL_MAX_EXP__=16384 '-D__LDBL_MAX__=1.18973149535723176502e+4932L' '-D__LDBL_MIN_10_EXP__=(-4931)' '-D__LDBL_MIN_EXP__=(-16381)' -D__LDBL_MIN__=3.36210314311209350626e-4932L -D__LITTLE_ENDIAN__=1 -D__LLONG_WIDTH__=64 -D__LONG_LONG_MAX__=9223372036854775807LL -D__LONG_MAX__=9223372036854775807L -D__LONG_WIDTH__=64 -D__LP64__=1 -D__MMX__=1 -D__NO_INLINE__=1 -D__NO_MATH_INLINES=1 -D__OBJC_BOOL_IS_BOOL=0 -D__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES=3 -D__OPENCL_MEMORY_SCOPE_DEVICE=2 -D__OPENCL_MEMORY_SCOPE_SUB_GROUP=4 -D__OPENCL_MEMORY_SCOPE_WORK_GROUP=1 -D__OPENCL_MEMORY_SCOPE_WORK_ITEM=0 -D__ORDER_BIG_ENDIAN__=4321 -D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_PDP_ENDIAN__=3412 -D__PIC__=2 -D__PIE__=2 -D__POINTER_WIDTH__=64 -D__PRAGMA_REDEFINE_EXTNAME=1 '-D__PTRDIFF_FMTd__="ld"' '-D__PTRDIFF_FMTi__="li"' -D__PTRDIFF_MAX__=9223372036854775807L '-D__PTRDIFF_TYPE__=long int' -D__PTRDIFF_WIDTH__=64 -D__REGISTER_PREFIX__= -D__SCHAR_MAX__=127 -D__SEG_FS=1 -D__SEG_GS=1 -D__SHRT_MAX__=32767 -D__SHRT_WIDTH__=16 -D__SIG_ATOMIC_MAX__=2147483647 -D__SIG_ATOMIC_WIDTH__=32 -D__SIZEOF_DOUBLE__=8 -D__SIZEOF_FLOAT128__=16 -D__SIZEOF_FLOAT__=4 -D__SIZEOF_INT128__=16 -D__SIZEOF_INT__=4 -D__SIZEOF_LONG_DOUBLE__=16 -D__SIZEOF_LONG_LONG__=8 -D__SIZEOF_LONG__=8 -D__SIZEOF_POINTER__=8 -D__SIZEOF_PTRDIFF_T__=8 -D__SIZEOF_SHORT__=2 -D__SIZEOF_SIZE_T__=8 -D__SIZEOF_WCHAR_T__=4 -D__SIZEOF_WINT_T__=4 '-D__SIZE_FMTX__="lX"' '-D__SIZE_FMTo__="lo"' '-D__SIZE_FMTu__="lu"' '-D__SIZE_FMTx__="lx"' -D__SIZE_MAX__=18446744073709551615UL '-D__SIZE_TYPE__=long unsigned int' -D__SIZE_WIDTH__=64 -D__SSE2_MATH__=1 -D__SSE2__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__STDCPP_DEFAULT_NEW_ALIGNMENT__=16UL -D__STDCPP_THREADS__=1 -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -D__UINT16_C_SUFFIX__= '-D__UINT16_FMTX__="hX"' '-D__UINT16_FMTo__="ho"' '-D__UINT16_FMTu__="hu"' '-D__UINT16_FMTx__="hx"' -D__UINT16_MAX__=65535 '-D__UINT16_TYPE__=unsigned short' -D__UINT32_C_SUFFIX__=U '-D__UINT32_FMTX__="X"' '-D__UINT32_FMTo__="o"' '-D__UINT32_FMTu__="u"' '-D__UINT32_FMTx__="x"' -D__UINT32_MAX__=4294967295U '-D__UINT32_TYPE__=unsigned int' -D__UINT64_C_SUFFIX__=UL '-D__UINT64_FMTX__="lX"' '-D__UINT64_FMTo__="lo"' '-D__UINT64_FMTu__="lu"' '-D__UINT64_FMTx__="lx"' -D__UINT64_MAX__=18446744073709551615UL '-D__UINT64_TYPE__=long unsigned int' -D__UINT8_C_SUFFIX__= '-D__UINT8_FMTX__="hhX"' '-D__UINT8_FMTo__="hho"' '-D__UINT8_FMTu__="hhu"' '-D__UINT8_FMTx__="hhx"' -D__UINT8_MAX__=255 '-D__UINT8_TYPE__=unsigned char' -D__UINTMAX_C_SUFFIX__=UL '-D__UINTMAX_FMTX__="lX"' '-D__UINTMAX_FMTo__="lo"' '-D__UINTMAX_FMTu__="lu"' '-D__UINTMAX_FMTx__="lx"' -D__UINTMAX_MAX__=18446744073709551615UL '-D__UINTMAX_TYPE__=long unsigned int' -D__UINTMAX_WIDTH__=64 '-D__UINTPTR_FMTX__="lX"' '-D__UINTPTR_FMTo__="lo"' '-D__UINTPTR_FMTu__="lu"' '-D__UINTPTR_FMTx__="lx"' -D__UINTPTR_MAX__=18446744073709551615UL '-D__UINTPTR_TYPE__=long unsigned int' -D__UINTPTR_WIDTH__=64 '-D__UINT_FAST16_FMTX__="hX"' '-D__UINT_FAST16_FMTo__="ho"' '-D__UINT_FAST16_FMTu__="hu"' '-D__UINT_FAST16_FMTx__="hx"' -D__UINT_FAST16_MAX__=65535 '-D__UINT_FAST16_TYPE__=unsigned short' '-D__UINT_FAST32_FMTX__="X"' '-D__UINT_FAST32_FMTo__="o"' '-D__UINT_FAST32_FMTu__="u"' '-D__UINT_FAST32_FMTx__="x"' -D__UINT_FAST32_MAX__=4294967295U '-D__UINT_FAST32_TYPE__=unsigned int' '-D__UINT_FAST64_FMTX__="lX"' '-D__UINT_FAST64_FMTo__="lo"' '-D__UINT_FAST64_FMTu__="lu"' '-D__UINT_FAST64_FMTx__="lx"' -D__UINT_FAST64_MAX__=18446744073709551615UL '-D__UINT_FAST64_TYPE__=long unsigned int' '-D__UINT_FAST8_FMTX__="hhX"' '-D__UINT_FAST8_FMTo__="hho"' '-D__UINT_FAST8_FMTu__="hhu"' '-D__UINT_FAST8_FMTx__="hhx"' -D__UINT_FAST8_MAX__=255 '-D__UINT_FAST8_TYPE__=unsigned char' '-D__UINT_LEAST16_FMTX__="hX"' '-D__UINT_LEAST16_FMTo__="ho"' '-D__UINT_LEAST16_FMTu__="hu"' '-D__UINT_LEAST16_FMTx__="hx"' -D__UINT_LEAST16_MAX__=65535 '-D__UINT_LEAST16_TYPE__=unsigned short' '-D__UINT_LEAST32_FMTX__="X"' '-D__UINT_LEAST32_FMTo__="o"' '-D__UINT_LEAST32_FMTu__="u"' '-D__UINT_LEAST32_FMTx__="x"' -D__UINT_LEAST32_MAX__=4294967295U '-D__UINT_LEAST32_TYPE__=unsigned int' '-D__UINT_LEAST64_FMTX__="lX"' '-D__UINT_LEAST64_FMTo__="lo"' '-D__UINT_LEAST64_FMTu__="lu"' '-D__UINT_LEAST64_FMTx__="lx"' -D__UINT_LEAST64_MAX__=18446744073709551615UL '-D__UINT_LEAST64_TYPE__=long unsigned int' '-D__UINT_LEAST8_FMTX__="hhX"' '-D__UINT_LEAST8_FMTo__="hho"' '-D__UINT_LEAST8_FMTu__="hhu"' '-D__UINT_LEAST8_FMTx__="hhx"' -D__UINT_LEAST8_MAX__=255 '-D__UINT_LEAST8_TYPE__=unsigned char' -D__USER_LABEL_PREFIX__= '-D__VERSION__="Ubuntu Clang 15.0.7"' -D__WCHAR_MAX__=2147483647 -D__WCHAR_TYPE__=int -D__WCHAR_WIDTH__=32 -D__WINT_MAX__=4294967295U '-D__WINT_TYPE__=unsigned int' -D__WINT_UNSIGNED__=1 -D__WINT_WIDTH__=32 -D__amd64=1 -D__amd64__=1 -D__clang__=1 '-D__clang_literal_encoding__="UTF-8"' -D__clang_major__=15 -D__clang_minor__=0 -D__clang_patchlevel__=7 '-D__clang_version__="15.0.7 "' '-D__clang_wide_literal_encoding__="UTF-32"' -D__code_model_small__=1 -D__cpp_aggregate_nsdmi=201304L -D__cpp_alias_templates=200704L -D__cpp_attributes=200809L -D__cpp_binary_literals=201304L -D__cpp_constexpr=201304L -D__cpp_constexpr_in_decltype=201711L -D__cpp_decltype=200707L -D__cpp_decltype_auto=201304L -D__cpp_delegating_constructors=200604L -D__cpp_digit_separators=201309L -D__cpp_exceptions=199711L -D__cpp_generic_lambdas=201304L -D__cpp_impl_destroying_delete=201806L -D__cpp_inheriting_constructors=201511L -D__cpp_init_captures=201304L -D__cpp_initializer_lists=200806L -D__cpp_lambdas=200907L -D__cpp_nsdmi=200809L -D__cpp_range_based_for=200907 -D__cpp_raw_strings=200710L -D__cpp_ref_qualifiers=200710L -D__cpp_return_type_deduction=201304L -D__cpp_rtti=199711L -D__cpp_rvalue_references=200610L -D__cpp_static_assert=200410 -D__cpp_threadsafe_static_init=200806L -D__cpp_unicode_characters=200704L -D__cpp_unicode_literals=200710L -D__cpp_user_defined_literals=200809L -D__cpp_variable_templates=201304L -D__cpp_variadic_templates=200704L -D__gnu_linux__=1 -D__k8=1 -D__k8__=1 -D__linux=1 -D__linux__=1 -D__llvm__=1 -D__pic__=2 -D__pie__=2 -D__private_extern__=extern '-D__seg_fs=__attribute__((address_space(257)))' '-D__seg_gs=__attribute__((address_space(256)))' -D__tune_k8__=1 -D__unix=1 -D__unix__=1 -D__x86_64=1 -D__x86_64__=1 -Dlinux=1 -Dunix=1 '-I/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11' '-I/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11' '-I/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward' -I/usr/lib/llvm-15/lib/clang/15.0.7/include -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include -- test.cpp
[E 15:50:46 4121111] CODEQL_EXTRACTOR_CPP_TRAP_CACHING is not set
[E 15:50:46 4121111] CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_WRITE is not set
[E 15:50:46 4121111] CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_DIR is not set
[E 15:50:46 4121111] Initialising TRAP cache at path: 7b/8043/43d5403ac0817371255d0d4a19e4
[E 15:50:46 4121111] Not using TRAP cache
[E 15:50:46 4121111] TRAP cache miss
[E 15:50:46 4121111] Starting compilation TRAP ./compilations/24/14846835_0.trap.zst
"test.cpp", line 2: error: incomplete type "char []" is not allowed
    char *ptr = new char[]{ "str" };
                    ^

[E 15:50:46 4121111] Warning[extractor-c++]: In construct_text_message: "test.cpp", line 2: error: incomplete type "char []" is not allowed
    char *ptr = new char[]{ "str" };
                    ^


[E 15:50:46 4121111] Creating trap tarball ./tarballs/tmp/codeqltest/test.cpp.e6a82cc6_3.trap.tar.zst
[E 15:50:46 4121111] Emitting trap files for test.cpp
[E 15:50:46 4121111] Opening existencedb in ./existencedb/db
[E 15:50:46 4121111] Wrote 0 files to ./tarballs/tmp/codeqltest/test.cpp.e6a82cc6_3.trap.tar.zst
1 error detected in the compilation of "test.cpp".
[E 15:50:46 4121111] Finished compilation TRAP ./compilations/24/14846835_0.trap.zst
[E 15:50:46 4121111] Marking C compilation as happened.
[E 15:50:46 4121111] Setting tag c-compilation-happened
[E 15:50:46 4121111] Warning[extractor-c++]: In main: Extractor exiting with code 1
$ $(which clang++) --version
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ /usr/local/bin/codeql/cpp/tools/linux64/extractor --version
[E 15:51:13 4121114] CodeQL C/C++ Extractor 2.17.4
[E 15:51:13 4121114] CODEQL_EXTRACTOR_CPP_SCRATCH_DIR does not exist; not saving separate log file.
[E 15:51:13 4121114] Could not open log file; not saving separate log file.
[E 15:51:13 4121114] Current directory: /tmp/codeqltest
[E 15:51:13 4121114] Command: /usr/local/bin/codeql/cpp/tools/linux64/extractor --version
[E 15:51:13 4121114] Processed command line: /usr/local/bin/codeql/cpp/tools/linux64/extractor --version
Edison Design Group C/C++ Front End, version 6.6 (redacted redacted)
Copyright 1988-2023 Edison Design Group, Inc.

[E 15:51:13 4121114] Warning[extractor-c++]: In main: Extractor exiting with code 1
$

qwerty472123 avatar Jun 11 '24 07:06 qwerty472123

Thanks. I can reproduce the problem now, and have reported it to our frontend supplier.

jketema avatar Jun 13 '24 08:06 jketema

The __FILE_NAME__ issue will be fixed in CodeQL 2.22.0.

jketema avatar Jun 04 '25 13:06 jketema

The arm_neon.h parse errors will be resolved in CodeQL 2.22.2.

jketema avatar Jun 30 '25 19:06 jketema

The _Nonnull issue will also be resolved in CodeQL 2.22.2.

jketema avatar Jul 07 '25 06:07 jketema

The char *ptr = new char[]{ "str" }; issue will be fixed in CodeQL 2.22.4. I believe that addresses all the issues reported here. Closing this a completed.

jketema avatar Aug 11 '25 09:08 jketema