Status: New
Owner: ----
New issue 2149 by [email protected]: STATIC_ASSERT fails to compile with GCC
4.8 due to -Werror=unused-local-typedefs
http://code.google.com/p/v8/issues/detail?id=2149
GCC 4.8 has a new unused checking (or at least it is newly enabled by
-Wall): unused-local-typedefs.
As v8 is by default compiled with "-Wall -Werror", the compilation will
fail with as follows.
I see two possibilities:
(a) Compiling with -Wno-unused-local-typedefs [cf. patch far below]
(b) Modifying SEMI_STATIC_JOIN to prevent the warning
(and via -Werror the error)
The source code in question is src/checks.h:
-----------------------------
// This macro joins two tokens. If one of the tokens is a macro the
// helper call causes it to be resolved before joining.
#define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b)
#define SEMI_STATIC_JOIN_HELPER(a, b) a##b
// Causes an error during compilation of the condition is not
// statically known to be true. It is formulated as a typedef so that
// it can be used wherever a typedef can be used. Beware that this
// actually causes each use to introduce a new defined type with a
// name depending on the source line.
template <int> class StaticAssertionHelper { };
#define
STATIC_CHECK(test) \
typedef
\
StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
-----------------------------
And the GCC compiler warning/error is:
$ g++ ... -Wall -Werror ... ../src/conversions.cc
In file included from ../src/utils.h:36:0,
from ../src/conversions.h:31,
from ../src/conversions-inl.h:40,
from ../src/conversions.cc:32:
../src/scanner.h: In member function 'void v8::internal::Scanner::Init()':
../src/checks.h:251:22: error: typedef '__StaticAssertTypedef__450' locally
defined but not used [-Werror=unused-local-typedefs]
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
^
../src/checks.h:241:39: note: in expansion of
macro 'SEMI_STATIC_JOIN_HELPER'
#define SEMI_STATIC_JOIN_HELPER(a, b) a##b
^
../src/checks.h:240:32: note: expanded from here
#define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b)
^
../src/checks.h:240:56: note: in expansion of macro 'SEMI_STATIC_JOIN'
#define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b)
^
../src/checks.h:251:5: note: expanded from here
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
^
../src/checks.h:251:22: note: in expansion of macro 'STATIC_CHECK'
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
^
../src/checks.h:283:30: note: expanded from here
#define STATIC_ASSERT(test) STATIC_CHECK(test)
^
../src/checks.h:283:30: note: in expansion of macro 'STATIC_ASSERT'
../src/scanner.h:450:5: note: expanded from here
STATIC_ASSERT(kCharacterLookaheadBufferSize == 1);
^
cc1plus: all warnings being treated as errors
-----------------------------
Possible patch for (a):
--- build/standalone.gypi (revision 11638)
+++ build/standalone.gypi (working copy)
@@ -92,7 +92,8 @@
'target_defaults': {
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-Wnon-virtual-dtor', '-pthread', '-fno-rtti',
- '-fno-exceptions', '-pedantic' ],
+ '-fno-exceptions', '-pedantic',
+ '-Wno-unused-local-typedefs' ],
'ldflags': [ '-pthread', ],
'conditions': [
[ 'OS=="linux"', {
--- build/common.gypi (revision 11638)
+++ build/common.gypi (working copy)
@@ -320,7 +320,8 @@
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or
OS=="netbsd"', {
'cflags':
[ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
- '-Wnon-virtual-dtor', '-Woverloaded-virtual' ],
+ '-Wnon-virtual-dtor', '-Woverloaded-virtual',
+ '-Wno-unused-local-typedefs' ],
}],
],
}, # Debug
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev