Skip to content

MS Build: disable warnings about non-lvalue array conversions to pointers

MS Build compilation produces numerous warnings like:

  C:\GitLab-Runner\builds\graphviz\graphviz\lib\pathplan\shortest.c(376,37):
    warning C4223: nonstandard extension used: non-lvalue array converted to
    pointer
    [C:\GitLab-Runner\builds\graphviz\graphviz\lib\pathplan\Pathplan.vcxproj]

The code in question looks like:

  if (triangles_get(&tris, trii).e[ei].right_index != SIZE_MAX &&
  

triangles_get returns a struct which contains a member, e, with array type. Trying to determine what MSVC is referring to here, eventually leads one to an old comp.lang discussion.¹ The relevant detail in that thread is a change between ISO C90 and ISO C99:²

Major changes from the previous edition include:

— conversion of array to pointer not limited to lvalue

So under C90 semantics, triangles_get(&tris, trii).e would have array type while under C99 semantics it has pointer type.³ MSVC notoriously is not fully compliant with C99. But in this case, it appears to be warning us it is applying the C99 semantics. This is all somewhat irrelevant anyway, as the full containing expression has identical semantics in C90 and C99.⁴

This change disables the warning, which appears to be pure noise for the Graphviz build.

¹ https://groups.google.com/g/comp.std.c/c/JdBboqdWzns
² ISO C99 Forward p5
³ Thankfully to simplify the concerns we currently have, this code was introduced after Graphviz switched to being compiled under C99.
⁴ ISO C90 §6.3.2.1p2 and its counterpart ISO C99 §6.5.2.1p2 make clear the evaluation of array subscripting is not dependent on this detail.

Edited by Matthew Fernandez

Merge request reports