From f8a75ca667a1d27be2a304502edd01d064cce20a Mon Sep 17 00:00:00 2001 From: Jesse Schalken Date: Wed, 21 Sep 2016 07:43:46 -0700 Subject: [PATCH] Fix "flexible array member in an otherwise empty struct" error on GCC 6.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes the following error on GCC 6.2: ``` In file included from /hphp/runtime/base/rds-header.h:24:0, from /hphp/runtime/base/request-injection-data.h:20, from /hphp/runtime/base/thread-info.h:24, from /hphp/runtime/base/array-init.h:26, from /hphp/system/systemlib.cpp:18: /hphp/runtime/vm/bytecode.h: At global scope: /hphp/runtime/vm/bytecode.h:128:26: error: flexible array member ‘HPHP::ExtraArgs::m_extraArgs’ in an otherwise empty ‘struct HPHP::ExtraArgs’ TypedValue m_extraArgs[]; ^ /hphp/runtime/vm/bytecode.h:80:8: note: in the definition of ‘struct HPHP::ExtraArgs’ struct ExtraArgs { ^~~~~~~~~ ``` Closes #6933 Closes https://github.com/facebook/hhvm/pull/7374 Differential Revision: D3899402 Pulled By: aorenste fbshipit-source-id: 9d7c7de1ee9607e50db584ac8a58b8aaa8cdf5fc --- hphp/runtime/vm/bytecode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hphp/runtime/vm/bytecode.h b/hphp/runtime/vm/bytecode.h index 6897ff2..22a3c5e 100644 --- a/hphp/runtime/vm/bytecode.h +++ b/hphp/runtime/vm/bytecode.h @@ -125,7 +125,7 @@ struct ExtraArgs { static void* allocMem(unsigned nargs); private: - TypedValue m_extraArgs[]; + TypedValue m_extraArgs[0]; }; /* diff -ur hhvm-HHVM-3.3.7/hphp/hhbbc/interp.cpp hhvm-HHVM-3.3.7-gcc6/hphp/hhbbc/interp.cpp --- hhvm-HHVM-3.3.7/hphp/hhbbc/interp.cpp 2015-06-30 21:56:17.000000000 +0200 +++ hhvm-HHVM-3.3.7-gcc6/hphp/hhbbc/interp.cpp 2017-03-04 02:27:06.013033366 +0100 @@ -1998,26 +1998,53 @@ push(env, TInitCell); } -template -void floatFnImpl(ISS& env, Op op, Type nonConstType) { +void in(ISS& env, const bc::Floor&) { auto const t1 = popC(env); auto const v1 = tv(t1); if (v1) { if (v1->m_type == KindOfDouble) { constprop(env); - return push(env, dval(op(v1->m_data.dbl))); + return push(env, dval(floor(v1->m_data.dbl))); } if (v1->m_type == KindOfInt64) { constprop(env); - return push(env, dval(op(static_cast(v1->m_data.num)))); + return push(env, dval(floor(static_cast(v1->m_data.num)))); } } - push(env, nonConstType); + push(env, TDbl); } -void in(ISS& env, const bc::Floor&) { floatFnImpl(env, floor, TDbl); } -void in(ISS& env, const bc::Ceil&) { floatFnImpl(env, ceil, TDbl); } -void in(ISS& env, const bc::Sqrt&) { floatFnImpl(env, sqrt, TInitUnc); } +void in(ISS& env, const bc::Ceil&) { + auto const t1 = popC(env); + auto const v1 = tv(t1); + if (v1) { + if (v1->m_type == KindOfDouble) { + constprop(env); + return push(env, dval(ceil(v1->m_data.dbl))); + } + if (v1->m_type == KindOfInt64) { + constprop(env); + return push(env, dval(ceil(static_cast(v1->m_data.num)))); + } + } + push(env, TDbl); +} + +void in(ISS& env, const bc::Sqrt&) { + auto const t1 = popC(env); + auto const v1 = tv(t1); + if (v1) { + if (v1->m_type == KindOfDouble) { + constprop(env); + return push(env, dval(sqrt(v1->m_data.dbl))); + } + if (v1->m_type == KindOfInt64) { + constprop(env); + return push(env, dval(sqrt(static_cast(v1->m_data.num)))); + } + } + push(env, TInitUnc); +} void in(ISS& env, const bc::CheckProp&) { push(env, TBool); } void in(ISS& env, const bc::InitProp& op) { diff -ur hhvm-HHVM-3.3.7/hphp/runtime/vm/bytecode.cpp hhvm-HHVM-3.3.7-gcc6/hphp/runtime/vm/bytecode.cpp --- hhvm-HHVM-3.3.7/hphp/runtime/vm/bytecode.cpp 2015-06-30 21:56:17.000000000 +0200 +++ hhvm-HHVM-3.3.7-gcc6/hphp/runtime/vm/bytecode.cpp 2017-03-04 02:29:34.796789697 +0100 @@ -7211,22 +7211,20 @@ } } -template -OPTBLD_INLINE void ExecutionContext::roundOpImpl(Op op) { +OPTBLD_INLINE void ExecutionContext::iopFloor(IOP_ARGS) { + NEXT(); TypedValue* val = vmStack().topTV(); tvCastToDoubleInPlace(val); - val->m_data.dbl = op(val->m_data.dbl); -} - -OPTBLD_INLINE void ExecutionContext::iopFloor(IOP_ARGS) { - NEXT(); - roundOpImpl(floor); + val->m_data.dbl = floor(val->m_data.dbl); } OPTBLD_INLINE void ExecutionContext::iopCeil(IOP_ARGS) { NEXT(); - roundOpImpl(ceil); + TypedValue* val = vmStack().topTV(); + + tvCastToDoubleInPlace(val); + val->m_data.dbl = ceil(val->m_data.dbl); } OPTBLD_INLINE void ExecutionContext::iopCheckProp(IOP_ARGS) { diff -ur hhvm-HHVM-3.3.7/hphp/runtime/vm/jit/code-gen-x64.cpp hhvm-HHVM-3.3.7.gcc6/hphp/runtime/vm/jit/code-gen-x64.cpp --- hhvm-HHVM-3.3.7/hphp/runtime/vm/jit/code-gen-x64.cpp 2015-06-30 21:56:17.000000000 +0200 +++ hhvm-HHVM-3.3.7.gcc6/hphp/runtime/vm/jit/code-gen-x64.cpp 2017-03-04 10:55:38.602703009 +0100 @@ -3785,7 +3785,8 @@ : calleeNumParams + 1; v << kpcall{extra->knownPrologue, extra->callee, prologIndex}; } else { - v << call{extra->knownPrologue}; + RegSet argRegs; + v << call{extra->knownPrologue, argRegs}; } return; }