public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101029] New: unexpected error: non-constant condition for static assertion in gcc 10/11, but not 9 (clang also fine)
@ 2021-06-11 12:04 jim.w.walker at gmail dot com
  2021-06-11 12:05 ` [Bug c++/101029] " jim.w.walker at gmail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jim.w.walker at gmail dot com @ 2021-06-11 12:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101029

            Bug ID: 101029
           Summary: unexpected error: non-constant condition for static
                    assertion in gcc 10/11, but not 9 (clang also fine)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jim.w.walker at gmail dot com
  Target Milestone: ---

Created attachment 50984
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50984&action=edit
Output from -save-temps

A recent change to use unity builds in a product
(https://github.com/couchbase/kv_engine) I work on produced a build failure
which only occurred on our gcc 10.2 builder, it was fine on clang based builds. 

Further debugging of the issue revealed it appears to build fine on gcc 9. This
investigation also revealed I could make an unrelated code change preceding the
use of a templated type, and the code would then compile (details of this are
below). So far my conclusion is that this is an issue in gcc.

When compiled on gcc 10.2 the following error is seen.

/opt/gcc-10.2.0/include/c++/10.2.0/type_traits: In instantiation of ‘struct
std::is_default_constructible<const char>’:
/opt/gcc-10.2.0/include/c++/10.2.0/type_traits:143:12:   required from ‘struct
std::__and_<std::is_default_constructible<const char>,
std::is_default_constructible<char>,
std::__not_<std::__and_<std::__is_implicitly_default_constructible<const char>,
std::__is_implicitly_default_constructible<char> > > >’
/opt/gcc-10.2.0/include/c++/10.2.0/bits/stl_pair.h:244:59:   required by
substitution of ‘template<class _U1, class _U2, typename
std::enable_if<std::__and_<std::is_default_constructible<_U1>,
std::is_default_constructible<_U2>,
std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>,
std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type
<anonymous> > constexpr std::pair<const char, char>::pair() [with _U1 = const
char; _U2 = char; typename
std::enable_if<std::__and_<std::is_default_constructible<_U1>,
std::is_default_constructible<_U2>,
std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>,
std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type
<anonymous> = <missing>]’
tlm/deps/folly.exploded/include/folly/AtomicHashArray-inl.h:63:19:   required
from here
/opt/gcc-10.2.0/include/c++/10.2.0/type_traits:918:52: error: non-constant
condition for static assertion
  918 |      
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      |                    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

The complete gcc command used (this generated the attached file):

/opt/gcc-10.2.0/bin/g++
-DDESTINATION_ROOT=\"/mnt/Code/couchbase/docker/install\" -DEP_USE_ROCKSDB=1
-DFMT_LOCALE -DGLOG_NO_ABBREVIATED_SEVERITIES -DGOOGLE_GLOG_DLL_DECL=""
-DHAVE_BREAKPAD -DHAVE_JEMALLOC -DHAVE_JEMALLOC_SDALLOCX
-DLIBCOUCHSTORE_NO_VISIBILITY
-DMEMCACHED_VERSION=\"5c9636b6d00bf1f53f1302b7d76eee3ba9c0cd0d\"
-DOBJECT_ROOT=\"/home/couchbase/couchbase/kv_engine\"
-DPRODUCT_VERSION=\"0.0.0-0000\"
-DSOURCE_ROOT=\"/mnt/Code/couchbase/docker/kv_engine\" -DSPDLOG_COMPILED_LIB
-DSPDLOG_FMT_EXTERNAL -DSPDLOG_LEVEL_NAMES="{\"TRACE\", \"DEBUG\", \"INFO\",
\"WARNING\", \"ERROR\", \"CRITICAL\", \"OFF\"}" -D_FILE_OFFSET_BITS=64
-D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS -D__EXTENSIONS__=1
-D__STDC_FORMAT_MACROS -Dgsl_CONFIG_CONTRACT_VIOLATION_THROWS
-Itlm/deps/prometheus-cpp.exploded/include -Ikv_engine/engines/ep
-Icouchstore/include -I/mnt/Code/couchbase/docker/couchstore/include
-I/mnt/Code/couchbase/docker/kv_engine/include
-I/mnt/Code/couchbase/docker/kv_engine/tracing
-I/mnt/Code/couchbase/docker/kv_engine/utilities
-I/mnt/Code/couchbase/docker/kv_engine
-I/mnt/Code/couchbase/docker/platform/external
-I/mnt/Code/couchbase/docker/platform/include
-Itlm/deps/flatbuffers.exploded/include -Itlm/deps/snappy.exploded/include
-Ikv_engine/engines/ep/src
-I/mnt/Code/couchbase/docker/kv_engine/engines/ep/src
-I/mnt/Code/couchbase/docker/kv_engine/engines/ep
-I/mnt/Code/couchbase/docker/install/include -Ikv_engine/include
-Iplatform/include
-I/mnt/Code/couchbase/docker/kv_engine/engines/ep/tools/couchfile_upgrade
-I/mnt/Code/couchbase/docker/third_party/spdlog/include -isystem
/mnt/Code/couchbase/docker/third_party/HdrHistogram_c/src -isystem
/mnt/Code/couchbase/docker/phosphor/include -isystem
tlm/deps/boost.exploded/include -isystem tlm/deps/json.exploded/include
-isystem /mnt/Code/couchbase/docker/third_party/gsl-lite/include -isystem
tlm/deps/libevent.exploded/include -isystem tlm/deps/openssl.exploded/include
-isystem tlm/deps/jemalloc.exploded/include -isystem
tlm/deps/rocksdb.exploded/include -isystem
/mnt/Code/couchbase/docker/third_party/googletest/googletest/include -isystem
/mnt/Code/couchbase/docker/third_party/googletest/googlemock/include -isystem
tlm/deps/folly.exploded/include -isystem
tlm/deps/double-conversion.exploded/include -isystem
tlm/deps/glog.exploded/include -isystem tlm/deps/fmt.exploded/include -isystem
tlm/deps/zlib.exploded/include -isystem
/home/couchbase/couchbase/tlm/deps/breakpad.exploded/include/breakpad
-fvisibility=hidden -pthread -pedantic -Wall -Wredundant-decls
-Werror=missing-braces -fno-strict-aliasing -Werror=switch -g -fPIC
-ftls-model=initial-exec -std=c++17 -MD -MT
kv_engine/engines/ep/CMakeFiles/ep_objs.dir/Unity/unity_3_cxx.cxx.o -MF
kv_engine/engines/ep/CMakeFiles/ep_objs.dir/Unity/unity_3_cxx.cxx.o.d -o
kv_engine/engines/ep/CMakeFiles/ep_objs.dir/Unity/unity_3_cxx.cxx.o -c
/mnt/Code/couchbase/docker/kv_engine/engines/ep/src/dcp/producer.cc -save-temps

Please find attached the -save-temps output from a failing build. The cc source
as input here is as small as I could get and keep the error reproduced. It is
completely non-functional but still quite large as a number of library
depdendencies (all open source) get embedded into the output.

As for "unrelated code change allows the code to build":

In the orginal c++ source file, we have a function call for some logging. The
call looks like logger->warn("{}", vbucket). It is the type of the parameter
that can influence if the build errors or succeeds.

In the attached file, this can be seen at line 110615, when I changed that call
to log the uint32_t parameter, the code builds, e.g.

- logger->warn("{}", vbucket);
+ logger->warn("{}", opaque);

This function and the 'vbucket' type are, I'm sure, unrelated from the
templated type on 110619 which is the source of the compiler error.

Note on comparing gcc 9/10/11:

The easiest path for me to test against 9/10/11 in this instance was to compile
using -E, take that output and strip away various external dependencies
(/usr/include and the stdlib etc..) and then use that code in godbolt to try
different gcc compiler. Using this technique I could get object code from gcc
9, but the same error on 10.2, 10.3 and 11.1

This code was used in that test
https://gist.github.com/jimwwalker/d62677965feb347f50c4c11bddc7ab6f

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-07-06  6:49 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 12:04 [Bug c++/101029] New: unexpected error: non-constant condition for static assertion in gcc 10/11, but not 9 (clang also fine) jim.w.walker at gmail dot com
2021-06-11 12:05 ` [Bug c++/101029] " jim.w.walker at gmail dot com
2021-06-11 12:17 ` marxin at gcc dot gnu.org
2021-06-11 12:22 ` redi at gcc dot gnu.org
2021-06-11 13:41 ` marxin at gcc dot gnu.org
2021-06-11 13:42 ` marxin at gcc dot gnu.org
2021-06-11 20:45 ` jason at gcc dot gnu.org
2021-06-11 22:20 ` [Bug c++/101029] [10/11/12 regression] " jason at gcc dot gnu.org
2021-06-12 16:40 ` cvs-commit at gcc dot gnu.org
2021-06-16  9:03 ` jim.w.walker at gmail dot com
2021-06-16  9:16 ` redi at gcc dot gnu.org
2021-06-16 18:33 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:38 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:39 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:39 ` cvs-commit at gcc dot gnu.org
2021-07-06  6:49 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).