Skip to content

Commit

Permalink
fix Issue 13907 - Surrogate pairs in wchar string literal will cause …
Browse files Browse the repository at this point in the history
…incorrect length match

Stop considering lengthen conversion in StringExp::implicitConvTo().
  • Loading branch information
9rnsr committed Dec 29, 2014
1 parent 3295578 commit 18463cc
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/cast.c
Expand Up @@ -577,15 +577,19 @@ MATCH implicitConvTo(Expression *e, Type *t)
case Tsarray:
if (e->type->ty == Tsarray)
{
if (((TypeSArray *)e->type)->dim->toInteger() !=
((TypeSArray *)t)->dim->toInteger())
return;
TY tynto = t->nextOf()->ty;
if (tynto == tyn)
{
result = MATCHexact;
if (((TypeSArray *)e->type)->dim->toInteger() ==
((TypeSArray *)t)->dim->toInteger())
{
result = MATCHexact;
}
return;
}
int szto = t->nextOf()->size();
if (e->length(szto) != ((TypeSArray *)t)->dim->toInteger())
return;
if (!e->committed && (tynto == Tchar || tynto == Twchar || tynto == Tdchar))
{
result = MATCHexact;
Expand All @@ -594,10 +598,10 @@ MATCH implicitConvTo(Expression *e, Type *t)
}
else if (e->type->ty == Tarray)
{
if (e->length() >
((TypeSArray *)t)->dim->toInteger())
return;
TY tynto = t->nextOf()->ty;
int sznto = t->nextOf()->size();
if (e->length(sznto) != ((TypeSArray *)t)->dim->toInteger())
return;
if (tynto == tyn)
{
result = MATCHexact;
Expand All @@ -609,6 +613,7 @@ MATCH implicitConvTo(Expression *e, Type *t)
return;
}
}
/* fall through */
case Tarray:
case Tpointer:
Type *tn = t->nextOf();
Expand Down

0 comments on commit 18463cc

Please sign in to comment.