clang-tidy default checks (unknown origin) - c++

My clang-tidy seems to have some hardcoded options I cannot get rid of, without any .clang-file (as seen in --explain-config below):
clang-tidy --checks=-* --dump-config
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: <my user>
CheckOptions:
llvm-else-after-return.WarnOnConditionVariables: 'false'
modernize-loop-convert.MinConfidence: reasonable
modernize-replace-auto-ptr.IncludeStyle: llvm
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
google-readability-namespace-comments.ShortNamespaceLines: '10'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
google-readability-braces-around-statements.ShortStatementLines: '1'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
google-readability-namespace-comments.SpacesBeforeComments: '2'
modernize-loop-convert.MaxCopySize: '16'
modernize-pass-by-value.IncludeStyle: llvm
modernize-use-nullptr.NullMacros: 'NULL'
llvm-qualified-auto.AddConstToQualified: 'false'
modernize-loop-convert.NamingStyle: CamelCase
llvm-else-after-return.WarnOnUnfixable: 'false'
google-readability-function-size.StatementThreshold: '800'
...
Where are those coming of and how can I get rid of them ?
I discovered this by trying hard to overwrite readability-braces-around-statements.ShortNamespaceLines, but the default google-readability-braces-around-statements always win, unmovable.
No explanation when asked explicitly:
clang-tidy --dump-config --explain-config
'clang-analyzer-apiModeling.Errno' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.StdCLibraryFunctions' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.TrustNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.TrustReturnsNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.google.GTest' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.llvm.CastValue' is enabled in the clang-tidy binary.
'clang-analyzer-apiModeling.llvm.ReturnValue' is enabled in the clang-tidy binary.
'clang-analyzer-core.CallAndMessage' is enabled in the clang-tidy binary.
'clang-analyzer-core.CallAndMessageModeling' is enabled in the clang-tidy binary.
'clang-analyzer-core.DivideZero' is enabled in the clang-tidy binary.
'clang-analyzer-core.DynamicTypePropagation' is enabled in the clang-tidy binary.
'clang-analyzer-core.NonNullParamChecker' is enabled in the clang-tidy binary.
'clang-analyzer-core.NonnilStringConstants' is enabled in the clang-tidy binary.
'clang-analyzer-core.NullDereference' is enabled in the clang-tidy binary.
'clang-analyzer-core.StackAddrEscapeBase' is enabled in the clang-tidy binary.
'clang-analyzer-core.StackAddressEscape' is enabled in the clang-tidy binary.
'clang-analyzer-core.UndefinedBinaryOperatorResult' is enabled in the clang-tidy binary.
'clang-analyzer-core.VLASize' is enabled in the clang-tidy binary.
'clang-analyzer-core.builtin.BuiltinFunctions' is enabled in the clang-tidy binary.
'clang-analyzer-core.builtin.NoReturnFunctions' is enabled in the clang-tidy binary.
'clang-analyzer-core.uninitialized.ArraySubscript' is enabled in the clang-tidy binary.
'clang-analyzer-core.uninitialized.Assign' is enabled in the clang-tidy binary.
'clang-analyzer-core.uninitialized.Branch' is enabled in the clang-tidy binary.
'clang-analyzer-core.uninitialized.CapturedBlockVariable' is enabled in the clang-tidy binary.
'clang-analyzer-core.uninitialized.UndefReturn' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.InnerPointer' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.Move' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.NewDelete' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.NewDeleteLeaks' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.PlacementNew' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.PureVirtualCall' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.SelfAssignment' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.SmartPtrModeling' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.StringChecker' is enabled in the clang-tidy binary.
'clang-analyzer-cplusplus.VirtualCallModeling' is enabled in the clang-tidy binary.
'clang-analyzer-deadcode.DeadStores' is enabled in the clang-tidy binary.
'clang-analyzer-fuchsia.HandleChecker' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullPassedToNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullReturnedFromNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullabilityBase' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullableDereferenced' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullablePassedToNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-nullability.NullableReturnedFromNonnull' is enabled in the clang-tidy binary.
'clang-analyzer-optin.cplusplus.UninitializedObject' is enabled in the clang-tidy binary.
'clang-analyzer-optin.cplusplus.VirtualCall' is enabled in the clang-tidy binary.
'clang-analyzer-optin.mpi.MPI-Checker' is enabled in the clang-tidy binary.
'clang-analyzer-optin.osx.OSObjectCStyleCast' is enabled in the clang-tidy binary.
'clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker' is enabled in the clang-tidy binary.
'clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker' is enabled in the clang-tidy binary.
'clang-analyzer-optin.performance.GCDAntipattern' is enabled in the clang-tidy binary.
'clang-analyzer-optin.performance.Padding' is enabled in the clang-tidy binary.
'clang-analyzer-optin.portability.UnixAPI' is enabled in the clang-tidy binary.
'clang-analyzer-osx.API' is enabled in the clang-tidy binary.
'clang-analyzer-osx.MIG' is enabled in the clang-tidy binary.
'clang-analyzer-osx.NSOrCFErrorDerefChecker' is enabled in the clang-tidy binary.
'clang-analyzer-osx.NumberObjectConversion' is enabled in the clang-tidy binary.
'clang-analyzer-osx.OSObjectRetainCount' is enabled in the clang-tidy binary.
'clang-analyzer-osx.ObjCProperty' is enabled in the clang-tidy binary.
'clang-analyzer-osx.SecKeychainAPI' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.AtSync' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.AutoreleaseWrite' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.ClassRelease' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.Dealloc' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.IncompatibleMethodTypes' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.Loops' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.MissingSuperCall' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.NSAutoreleasePool' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.NSError' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.NilArg' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.NonNilReturnValue' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.ObjCGenerics' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.RetainCount' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.RetainCountBase' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.SelfInit' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.SuperDealloc' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.UnusedIvars' is enabled in the clang-tidy binary.
'clang-analyzer-osx.cocoa.VariadicMethodTypes' is enabled in the clang-tidy binary.
'clang-analyzer-osx.coreFoundation.CFError' is enabled in the clang-tidy binary.
'clang-analyzer-osx.coreFoundation.CFNumber' is enabled in the clang-tidy binary.
'clang-analyzer-osx.coreFoundation.CFRetainRelease' is enabled in the clang-tidy binary.
'clang-analyzer-osx.coreFoundation.containers.OutOfBounds' is enabled in the clang-tidy binary.
'clang-analyzer-osx.coreFoundation.containers.PointerSizedValues' is enabled in the clang-tidy binary.
'clang-analyzer-security.FloatLoopCounter' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.SecuritySyntaxChecker' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.UncheckedReturn' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.bcmp' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.bcopy' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.bzero' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.decodeValueOfObjCType' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.getpw' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.gets' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.mkstemp' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.mktemp' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.rand' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.strcpy' is enabled in the clang-tidy binary.
'clang-analyzer-security.insecureAPI.vfork' is enabled in the clang-tidy binary.
'clang-analyzer-unix.API' is enabled in the clang-tidy binary.
'clang-analyzer-unix.DynamicMemoryModeling' is enabled in the clang-tidy binary.
'clang-analyzer-unix.Malloc' is enabled in the clang-tidy binary.
'clang-analyzer-unix.MallocSizeof' is enabled in the clang-tidy binary.
'clang-analyzer-unix.MismatchedDeallocator' is enabled in the clang-tidy binary.
'clang-analyzer-unix.Vfork' is enabled in the clang-tidy binary.
'clang-analyzer-unix.cstring.BadSizeArg' is enabled in the clang-tidy binary.
'clang-analyzer-unix.cstring.CStringModeling' is enabled in the clang-tidy binary.
'clang-analyzer-unix.cstring.NullArg' is enabled in the clang-tidy binary.
'clang-analyzer-valist.CopyToSelf' is enabled in the clang-tidy binary.
'clang-analyzer-valist.Uninitialized' is enabled in the clang-tidy binary.
'clang-analyzer-valist.Unterminated' is enabled in the clang-tidy binary.
'clang-analyzer-valist.ValistBase' is enabled in the clang-tidy binary.
'clang-analyzer-webkit.NoUncountedMemberChecker' is enabled in the clang-tidy binary.
'clang-analyzer-webkit.RefCntblBaseVirtualDtor' is enabled in the clang-tidy binary.
'clang-analyzer-webkit.UncountedLambdaCapturesChecker' is enabled in the clang-tidy binary.
Version:
clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 15.0.6
Optimized build.
Default target: x86_64-pc-windows-msvc
Host CPU: tigerlake
Update
The above example does not involve any .clang-tidy file.
clang-tidy --fix-errors seems to work with the following .clang-tidy, even if google-readability-braces-around-statements.ShortStatementLines stays 1 in the dumped config.
Checks: hicpp-*, readability-identifier-naming,
CheckOptions:
- { key: readability-identifier-naming.ClassCase, value: CamelCase}
# readability-braces-around-statements
# also see clang-format:InsertBraces
# aliases: hicpp-braces-around-statements, google-readability-braces-around-statements
# TODO: google-readability-braces-around-statements.ShortStatementLines is always there (--dump-config), 1, but won't be applied
- { key: google-readability-braces-around-statements.ShortStatementLines, value: 3}
- { key: hicpp-braces-around-statements.ShortStatementLines, value: 3}

When I run clang-tidy.exe --checks=-* --dump-config, I get the same output as you do:
The list of about 20 CheckOptions can be ignored, because these
options are for checks that are disabled.
The only "checks" still apparently enabled are clang-diagnostic-*,clang-analyzer-*.
These are "diagnostics" which -- unlike regular checks -- depend on corresponding clang compiler warnings being enabled as well. I.E. pass -- -Weverything at the end of your clang-tidy command line to enable all clang compiler warnings so that clang-diagnostic-*,clang-analyzer-* can notice them. Or you can enable only some clang warnings.
Anyway, when I take away the --dump-config parameter and run clang-tidy.exe --checks=-* mysourcefile.cpp, I get Error: no checks enabled. So clang-tidy is honoring --checks=-*, but the help text generated by --dump-config appears to be incorrect.
Running clang-tidy.exe --checks=-*,clang-diagnostic-*,clang-analyzer-* mysourcefile.cpp -- -Weverything produces the expected clang-diagnostic and clang-analyzer messages.
Your .clang-tidy file that includes the line:
Checks: hicpp-*, readability-identifier-naming,
should probably be modified so the line looks like this:
Checks: '-*,hicpp-*,readability-identifier-naming'
In this way, you are explicitly disabling all the regular clang-tidy checks before explicitly enabling only the hicpp and readability-identifier-naming checks.

Related

How to use llvm toolchain on Linux always by default

I'm trying to build linux docker image, that will use clang and llvm libs (compiler-rt, libunwind, libc++, ...) for build always by default. I've seen this question, but it uses CMake variables. I want to not have to make any edits to the projects themselves, so that llvm is always used by default. How can I achieve this?
You have to build llvm with special flags (full info):
-DLIBCXX_USE_COMPILER_RT=YES # compiler-rt in libc++
-DLIBCXXABI_USE_LLVM_UNWINDER=YES # libunwind in libc++
-DCLANG_DEFAULT_CXX_STDLIB=libc++ # libc++ as std lib in clang by default
-DCLANG_DEFAULT_RTLIB=compiler-rt # compiler-rt in clang by default
And update cc/c++ links:
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 800 \
--slave /usr/bin/c++ c++ /usr/bin/clang++

How to use SYSTEM headers with CMake and clang-tidy?

I am trying to use clang-tidy in my CMake (3.17.1) project however it crashes on the Catch2 test library header. Setting the Catch2 as a system header does not seem to help. The command invoked for clang-tidy contains the path to Catch2 as a system include directory yet the diagnostics is still printed for it. When trying to isolate it I have discovered that this does not actually work with clang-tidy:
clang-tidy src.cpp -- -Isystem/Path/to/header
It results in the header not being found at all. What I have learned somewhere (cannot find it now) was to make it actually two --extra-arg parameters of the clang-tidy instead:
clang-tidy --extra-arg=-Isystem --extra-arg=/Path/to/header src.cpp
This however does not work everywhere. On Windows I was able to make it work but on Linux it never worked in any form (together, separate, after --). How does one use the -isystem headers with clang-tidy on Linux? It is very confusing and inconsistent. Furthermore how to do it with CMake?
I have this:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
add_library(Catch2 STATIC Catch2/Catch2.cpp Catch2/include/Catch2/catch.hpp)
target_include_directories(Catch2 SYSTEM PUBLIC Catch2/include)
add_executable(SomeTest SomeTest/test.cpp)
target_link_libraries(Catch2)
The generated command line is rather convoluted (wrapping is mine for readability):
cmake
-E __run_co_compile
--tidy="clang-tidy-10;--extra-arg-before=--driver-mode=g++"
--source=../Sometest/test.cpp
--
/usr/bin/clang++-10
-isystem ../Catch2/include
-g
-std=gnu++17
-MD
-MT CMakeFiles/SomeTest.dir/projects/SomeTest/test.cpp.o
-MF CMakeFiles/SomeTest.dir/projects/SomeTest/FileTest.cpp.o.d
-o CMakeFiles/SomeTest.dir/projects/SomeTest/test.cpp.o
-c
../projects/SomeTest/test.cpp
In the output there are warnings from the Catch2 so the system in the include is just ignored seemingly. I have tried to force the --extra-arg via the CMAKE_CXX_CLANG_TIDY property:
set(CMAKE_CXX_CLANG_TIDY clang-tidy --extra-arg=-isystem --extra-arg=../Catch2/include)
but that does not seem to do the trick either.
I am following your repro as posted on LLVM bugtracker.
You are doing everything correctly: that is, marking Catch2 as system include with SYSTEM. clang-tidy is also behaving correctly: it only checks your source file test.cpp and doesn't fully check catch.hpp, only the macro expansion.
The problem is the outdated version of Catch2. hicpp-vararg warning has been silenced as of Catch2 2.12.2, so you need to update to at least that version. Moreover, apparently the core issue that hicpp-vararg reported upon has been fixed and this change is expected to be present in clang-tidy 11 release.

Specifying go build's version of C++

I'm trying to build a go project that uses a third party library (GDAL) that's written in C and C++. I've run into this error:
In file included from contour.cpp:31:0:
cpl_port.h:187:6: error: #error Must have C++11 or newer.
# error Must have C++11 or newer.
^
In file included from C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/type_traits:35:0,
from cpl_conv.h:372,
from contour.cpp:39:
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
Some searching tells me this is expected, and the fix is to simply set a flag on the compiler (not go related, but still pertinent).
I've read through go's documentation on building, and while it suggests it's possible to specify options to individual compilers, it doesn't explicitly spell out how, nor does it provide any examples.
I've tried the following just guessing, and while the go build command accepts them, they produce the same error, so they don't work.
go build -gcflags -std=gnu++11 -ldflags -std=gnu++11
go build -gcflags -std=c++11 -ldflags -std=c++11
go build -gcflags -std=c++11
go build -gcflags -std=all=gnu++11 -ldflags -std=all=gnu++11
How can I tell go to tell gcc to compile with C++11 or newer?
Edit: As requested by PeterSO:
H:\>go version
go version go1.10.2 windows/amd64
H:\>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ksexton\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=H:\ksexton\Go;
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ksexton\AppData\Local\Temp\go-build937852322=/tmp/go-build -gno-record-gcc-switches
H:\>gcc --version
gcc (tdm64-1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
H:\>g++ --version
g++ (tdm64-1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Command cgo
Using cgo with the go command
All the cgo CPPFLAGS and CFLAGS directives in a package are
concatenated and used to compile C files in that package. All the
CPPFLAGS and CXXFLAGS directives in a package are concatenated and
used to compile C++ files in that package. All the CPPFLAGS and FFLAGS
directives in a package are concatenated and used to compile Fortran
files in that package. All the LDFLAGS directives in any package in
the program are concatenated and used at link time. All the pkg-config
directives are concatenated and sent to pkg-config simultaneously to
add to each appropriate set of command-line flags.
On Windows:
set CGO_CXXFLAGS=-std=c++11

Coverity Self-Build can't build a C++17 application

I'm trying to use Coverity Scan with an embedded application written in C++17 (ARM GCC Embedded v7.2). The application itself builds well and error/warning-free; however, the Coverity Scan Self-Build tool (cov-analysis-linux64-2017.07, the latest) fails to compile certain C++ files with the following error (abridged):
[19888] EXECUTING: /home/pavel/opt/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/as -I . -I src -I src/os_config -I eigen -I senoval -I legilimens -I popcop/c++ -I build/current_build_info -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -meabi=5 -alms=build/lst/ch.lst -o build/obj/ch.o /tmp/ccK73Qaa.s
"/home/pavel/opt/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/include/c++/7.2.1/bits/c++17_warning.h", line 32:
error #35: #error directive: This file requires compiler and library
support for the ISO C++ 2017 standard. This support must be enabled
with the -std=c++17 or -std=gnu++17 compiler options.
#error This file requires compiler and library support \
^
As can be seen, the build tool did not pass the option -std=c++17 to the assembler. By the way, the application's own build system does not make direct calls to the assembler; the Self-Build tool does it on its own. This is how the Coverity Self-Build process is configured:
cov-configure --comptype gcc --compiler arm-none-eabi-gcc --template
make clean
cov-build --dir build/cov-int make -j8
cd build
tar czvf coverity.tgz cov-int
How do I configure the Self-Build tool to build C++17 code correctly?

GCC C++11 Debug builds, Release fails

I have a project I've been working for some time, always in debug.
Today I tried building a release, and it fails to compile throwing some very weird errors.
While the debug compiles without any warnings, release throws:
/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Both CMake builds have c++11 enabled:
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=gnu++11 -Wall -g")
set(CMAKE_CSS_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++11 -Wall")
How can I track What is causing the compilation errors in Release?
EDIT I am using Cmake 2.8 and have tried to compile with gcc-4.6.3 and 4.7.2 and both have the same problem.
EDIT#2 Problem persists when using -std=c++0x instead of c++11.
EDIT#3 Downgrading to g++4.6 did not do much help. The error now simply changed to:
/usr/include/c++/4.6/bits/c++0x_warning.h:32:2:etc...
EDIT#4 I have removed <thread> which first caused problems. Then it was <mutex> and <atomic>. Now it is any piece of code that uses std::shared_ptr<Blah>.
It seems to me as if Release does not want to compile with C++11 at all. Is this on purpose?
I bet the problem comes from this line:
set(CMAKE_CSS_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++11 -Wall")
Look, you set the variable CMAKE_CSS_FLAGS_RELEASE. Chances are you just wanted to set the variable CMAKE_CXX_FLAGS_RELEASE instead. That would explain why your c++11 is not enabled in release mode.
I have fixed the problem by simply removing the CXX_FLAG, and using CMake's add definitions:
add_definitions("-std=gnu++11")
I do not know why this made it work, and why debug worked but release didn't, but it made a big difference.