New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 821357 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Mar 2018
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: ----
Type: ----



Sign in to add a comment

Build failure: GCC 7.x fails with calls to CHECK() in constexpr

Project Member Reported by jose.dap...@lge.com, Mar 13 2018

Issue description

CHECK() includes asm() calls on several platforms (including armel, x86/x64 and arm64). So when it is called from a constexpr GCC fails complaining asm inside a constexpr is not allowed.

GCC versions: 7.2 and 7.3.

By C++11 and C++14 specifications, asm() is forbidden in 

Error log examples:
./../../../../../../../../upstream-chromium/src/base/strings/string_piece.h: In member function 'constexpr base::BasicStringPiece<STRING_TYPE>::value_type base::BasicStringPiece<STRING_TYPE>::operator[](base::BasicStringPiece<STRING_TYPE>::size_type) const':
../../../../../../../../../upstream-chromium/src/base/logging.h:542:3: error: 'asm' in 'constexpr' function
   asm volatile("bkpt #0; udf %0;" ::"i"(__COUNTER__ % 256))
   ^
../../../../../../../../../upstream-chromium/src/base/logging.h:557:5: note: in expansion of macro 'TRAP_SEQUENCE'
     TRAP_SEQUENCE();         \
     ^~~~~~~~~~~~~
../../../../../../../../../upstream-chromium/src/base/logging.h:605:28: note: in expansion of macro 'IMMEDIATE_CRASH'
   UNLIKELY(!(condition)) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS
                            ^~~~~~~~~~~~~~~
../../../../../../../../../upstream-chromium/src/base/strings/string_piece.h:223:5: note: in expansion of macro 'CHECK'
     CHECK(i < length_);
     ^~~~~
 

Comment 1 by jose.dap...@lge.com, Mar 13 2018

A clarification: this only fails in official_build mode. Otherwise the CHECK implementation will not use the asm implementation.
Project Member

Comment 2 by bugdroid1@chromium.org, Mar 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9679430d6d7ce5f89ebce66bd5722a265e281f53

commit 9679430d6d7ce5f89ebce66bd5722a265e281f53
Author: Jose Dapena Paz <jose.dapena@lge.com>
Date: Sat Mar 17 00:41:20 2018

GCC fix: wrap CHECK asm in lambda to support constexpr calls

CHECK() implementation for arm, arm64, x86 and x64 includes
asm() statements. Recently added bounds checks using it
on constexpr methods are breaking GCC build, as GCC follows
more strictly C++14/11 standard, that explicitely forbids
calling asm from constexpr.

But GCC does not complain if the asm statement is not
directly called from constexpr, but through a function
call. So wrap the GCC asm calls for IMMEDIATE_CRASH in
a lambda function.

Bug:  821357 
Change-Id: I9b806fa09eda872fb2b8e81cc79d8a4ea20e3e0b
Reviewed-on: https://chromium-review.googlesource.com/960861
Commit-Queue: José Dapena Paz <jose.dapena@lge.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543887}
[modify] https://crrev.com/9679430d6d7ce5f89ebce66bd5722a265e281f53/base/logging.h

Comment 3 by jose.dap...@lge.com, Mar 17 2018

Status: Fixed (was: Untriaged)

Sign in to add a comment