Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Issue 8724003: Fix build with GCC 4.7, which fails with "narrowing conversion of (Closed)

Created:
9 years ago by Tobias Burnus
Modified:
9 years ago
Reviewers:
Steven
CC:
v8-dev
Visibility:
Public.

Description

Fix build with GCC 4.7, which fails with "narrowing conversion of 'id' from 'int' to 'unsigned int' inside { } is ill-formed in C++11" Contributed by burnus@net-b.de Committed: http://code.google.com/p/v8/source/detail?r=10101

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -5 lines) Patch
M src/full-codegen.h View 2 chunks +2 lines, -2 lines 1 comment Download
M src/full-codegen.cc View 2 chunks +3 lines, -3 lines 1 comment Download

Messages

Total messages: 2 (0 generated)
Tobias Burnus
The patch unbreaks compilation of src/full-codegen.cc with GCC 4.7. The build fails due to -Werror=narrowing ...
9 years ago (2011-11-29 20:47:09 UTC) #1
Steven
9 years ago (2011-11-30 17:50:42 UTC) #2
Hi Tobias,

thanks for the patch. It LGTM. I will commit it. 

Some rambling:
I'm not particularly fond of using simple integral types as the representation
in the first place. Conceptually we only want to have some special constants
like kFunctionEntryId and kDeclarationsId and the ability to create a bunch of
new ids, but clearly we want to disallow mixing with other types or implicit
conversions altogether.

As an approximation one could use (still allows implicit conversions to integral
types, but not from) an enum like

enum AstNodeId {
  kInitialAstNodeId,
  kFunctionEntryId = 2,
  kDeclarationsId,
  kFunctionBodyId,
  kNoAstId = -1
};

which replaces the unsigned representation of ast ids. This one would only use
explicit casting in the generation of new values. However, that refactoring
would take you on a bug tour through the ast classes and the code generators :P

Cheers,
-- Steven

http://codereview.chromium.org/8724003/diff/1/src/full-codegen.cc
File src/full-codegen.cc (right):

http://codereview.chromium.org/8724003/diff/1/src/full-codegen.cc#newcode389
src/full-codegen.cc:389: BailoutEntry entry = { ast_id,
static_cast<unsigned>(masm_->pc_offset()) };
The static_cast is ok. All the stack check table entries have unsigned offsets.
Good to have an ASSERT(masm_->pc_offset()) though.

http://codereview.chromium.org/8724003/diff/1/src/full-codegen.h
File src/full-codegen.h (right):

http://codereview.chromium.org/8724003/diff/1/src/full-codegen.h#newcode393
src/full-codegen.h:393: void PrepareForBailoutForId(unsigned id, State state);
Indeed the ast node ids are represented by an 'unsigned'
everywhere else.

Powered by Google App Engine
This is Rietveld 408576698