Getting "invalid application of 'sizeof' to incomplete type" error when building

904 views
Skip to first unread message

misham

unread,
Jan 8, 2011, 8:28:11 PM1/8/11
to v8-users
Hello,

I am working on a PowerPC port for v8 (https://github.com/misham/v8)
and I'm trying to solve the following compiler error:

g++ -o obj/release/accessors.o -c -Wall -Werror -W -Wno-unused-
parameter -Wnon-virtual-dtor -pedantic -O3 -fomit-frame-pointer -fdata-
sections -ffunction-sections -ansi -fno-rtt
i -fno-exceptions -fvisibility=hidden -Wall -Werror -W -Wno-unused-
parameter -Wnon-virtual-dtor -pedantic -O3 -fomit-frame-pointer -fdata-
sections -ffunction-sections -ansi -DV8_TARGET_ARCH_PPC -
DENABLE_VMSTATE_TRACKING -DENABLE_LOGGING_AND_PROFILING -
DENABLE_DEBUGGER_SUPPORT -Isrc src/accessors.cc
In file included from src/v8.h:63,
from src/accessors.cc:28:
src/objects-inl.h:2873: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'
src/objects-inl.h:2880: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'
src/objects-inl.h:2883: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'
src/objects-inl.h:2890: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'
src/objects-inl.h:2897: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'

I've traced the call to the STATIC_CHECK macro (checks.h:254) but I do
not know why it's failing. Here's the macro:

template <int> class StaticAssertionHelper { };
#define
STATIC_CHECK(test) \

typedef
\

StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>(test)>)>
\
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)

Does anyone know why this error would be generated and what I can do
to fix it?

I am compiling on PowerPC Mac Mini running Ubuntu 10.10 with the
following command: scons arch=powerpc sample=shell

Thank you

- Misha

Stephan Beal

unread,
Jan 9, 2011, 5:17:28 AM1/9/11
to v8-u...@googlegroups.com
On Sun, Jan 9, 2011 at 2:28 AM, misham <mic...@manulis.com> wrote:
src/objects-inl.h:2873: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'

StaticAssertion<false> does not appear to be defined anywhere. This might be intentional, and is probably a sign that your build triggered a static assertion set up by the v8 developers.

stephan@ludo:~/src/google/v8/src$ grep 'StaticAssertion<' *
checks.h:template <> class StaticAssertion<true> { };
checks.h:    StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>(test)>)> \
stephan@ludo:~/src/google/v8/src$ cd ../include/
stephan@ludo:~/src/google/v8/include$ grep 'StaticAssertion<' *

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

Lasse R.H. Nielsen

unread,
Jan 9, 2011, 5:55:10 AM1/9/11
to v8-u...@googlegroups.com
Correct.
The StaticAssert macro is used to introduce compile-time assertions into the code.
The reported errors comes from static assertions that fail, i.e., something is not satisfying the assumptions that the remaining code depends on, and it's visible at
compile time, so we abort compilation with the StaticAssertion<false> failure.

The solution is to make the assumptions true again.
/L




--
Lasse R.H. Nielsen
l...@google.com
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K -
Denmark - CVR nr. 28 86 69 84

veg...@chromium.org

unread,
Jan 9, 2011, 6:02:08 AM1/9/11
to v8-users
> src/objects-inl.h:2873: error: invalid application of 'sizeof' to
> incomplete type 'StaticAssertion<false>'
> src/objects-inl.h:2880: error: invalid application of 'sizeof' to
> incomplete type 'StaticAssertion<false>'
> src/objects-inl.h:2883: error: invalid application of 'sizeof' to
> incomplete type 'StaticAssertion<false>'
> src/objects-inl.h:2890: error: invalid application of 'sizeof' to
> incomplete type 'StaticAssertion<false>'
> src/objects-inl.h:2897: error: invalid application of 'sizeof' to
> incomplete type 'StaticAssertion<false>'

It seems that kFormalParameterCountOffset and others hi-parts of
pseudo smis in SharedFunctionInfo are not aligned as expected.

What are values for kPointerSize and kIntSize on PowerPC?

--
Vyacheslav Egorov

misham

unread,
Jan 9, 2011, 2:15:23 PM1/9/11
to v8-users
Vyacheslav,

Here the sizeof results:

kPointerSize -> sizeof(void*) = 4
kIntSize -> sizeof(int) = 4

-- Misha

On Jan 9, 3:02 am, "vego...@chromium.org" <vego...@chromium.org>
wrote:

misham

unread,
Jan 9, 2011, 2:18:27 PM1/9/11
to v8-users
Lasse and Stephan,

Thanks, that makes sense. I'll work on implementing StaticAssertion.

- Misha

On Jan 9, 2:55 am, "Lasse R.H. Nielsen" <l...@chromium.org> wrote:
> Correct.
> The StaticAssert macro is used to introduce compile-time assertions into the
> code.
> The reported errors comes from static assertions that fail, i.e., something
> is not satisfying the assumptions that the remaining code depends on, and
> it's visible at
> compile time, so we abort compilation with the StaticAssertion<false>
> failure.
>
> The solution is to make the assumptions true again.
> /L
>
>
>
>
>
>
>
>
>
> On Sun, Jan 9, 2011 at 11:17, Stephan Beal <sgb...@googlemail.com> wrote:

veg...@chromium.org

unread,
Jan 9, 2011, 3:20:01 PM1/9/11
to v8-users

On Jan 9, 8:15 pm, misham <mich...@manulis.com> wrote:
> kPointerSize -> sizeof(void*) = 4
> kIntSize -> sizeof(int)   = 4

If kPointerSize == kIntSize == 4 then you should define
V8_HOST_ARCH_32_BIT. The pseudosmi accessors code which triggers these
static assertions is for 64bit arch.

> Thanks, that makes sense. I'll work on implementing StaticAssertion.

You should _not_ implement StaticAssertion. It is already implemented
and StaticAssertion<false> definition is omitted on purpose --- to
trigger compilation errors.

Let me show you an example... If you see something like

src/objects-inl.h:2873: error: invalid application of 'sizeof' to
incomplete type 'StaticAssertion<false>'

you should open the file in question, look at the line and then locate
relevant STATIC_ASSERT(expr) macro. In this case it is clearly the one
on line 2868

STATIC_ASSERT(holder::offset % kPointerSize == kIntSize);

Then you should look at the expression passed to STATIC_ASSERT and try
to figure out why it evaluates to false. In this case it evaluates to
false because kPointerSize == kIntSize. And PSEUDO_SMI_ACCESSORS_HI/
PSEUDO_SMI_ACCESSORS_LO are written in assumption that kPointerSize ==
2*kIntSize (+ little endianess assumption which is not documented or
checked by any assertion in this code).

Hope this helps.

--
Vyacheslav Egorov

misham

unread,
Jan 9, 2011, 4:27:23 PM1/9/11
to v8-users
Thanks for the explanation, defining V8_HOST_ARCH_32_BIT in globals.h
along with V8_HOST_ARCH_PPC solved that problem.


On Jan 9, 12:20 pm, "vego...@chromium.org" <vego...@chromium.org>
wrote:
Reply all
Reply to author
Forward
0 new messages