Don't accept strings too long to fit in char[N] with trailing NUL.

It was previously possible to assign "hello" to a variable backed by char[5]
storage in C, and the array contained the correct character data but without
the trailing NUL, which was unexpected in C.

This is not allowed any more, only "helo" can fit into a char[5] now and
anything else fails the type check, just as it already happened for the longer
strings before.

Closes #122
This commit is contained in:
Vadim Zeitlin 2013-12-23 20:47:43 +01:00 committed by William S Fulton
commit cdf1ba9120
4 changed files with 13 additions and 7 deletions

View file

@ -174,9 +174,9 @@ if t.var_namet != def_namet:
print "bad namet", t.var_namet, def_namet
raise RuntimeError
t.var_namet = 'holac'
t.var_namet = 'hola'
if t.var_namet != 'holac':
if t.var_namet != 'hola':
print "bad namet", t.var_namet
raise RuntimeError