Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 4) C4816

Error Message

'param' : parameter has a zero-sized array which will be truncated (unless the object is passed by reference)

A parameter to an object with a zero-size array was not passed by reference. The array will not get copied when the object is passed.


The following sample generates C4816:

// C4816.cpp
// compile with: /W4
#include <stdio.h>

extern "C" int printf_s(const char *, ...);

#pragma warning(disable : 4200)

struct S1
    int i;
    char cArr[];

void TestErr(S1 s1)   // C4816 param with zero-array 
                      // not passed by reference
    printf_s("%d %c %c\n", s1.i, s1.cArr[0], s1.cArr[1]);

void TestOk(S1 &s1)
    printf_s("%d %c %c\n", s1.i, s1.cArr[0], s1.cArr[1]);

int main()
    S1 myS_1 = { 6, 'a', 'b', 'c' };

Community Additions

© 2015 Microsoft