Skip to content

Clang warning of type -Wsizeof-array-div for arabic fallback shaping static assert #1969

Closed

Description

@drott

See https://bugs.chromium.org/p/chromium/issues/detail?id=1002945#c5

[1993/73487] CXX win_clang_nacl_win64/obj/third_party/harfbuzz-ng/harfbuzz_source/hb-ot-shape-complex-arabic.obj
In file included from ../../third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc:245:
../../third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh(233,68): warning: expression does not compute the number of elements in this array; element type is 'const unsigned char', not 'ManifestLookup' [-Wsizeof-array-div]
  static_assert (sizeof (arabic_win1256_gsub_lookups.manifestData) / sizeof ()
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
1 warning generated.

From a cursory inspection, this looks like it could be a true positive.

MANIFEST starts with OT_LABEL_START which places a
unsigned char Name[

whereas ManifestLookup is a Tag + Offset struct.

Activity

  1. added
    Chrome
    on Sep 14, 2019
  2. ebraminio commented on Sep 21, 2019

    @ebraminio
    Collaborator

    I would say just disable this platform specific encoding by HB_NO_WIN1256, it is for .fon font files(!) which Chrome doesn't support anyway (see f28b1c8, it needs Uniscribe's platform specific cmap callback, which Chrome doesn't have) and is intended for Firefox, I will turn it on our clang -Weverything CI bot and once we get that clang update on the bot (which uses very experimental clang also) we will fix that as well but you just don't need that.

  3. drott commented on Sep 23, 2019

    @drott
    CollaboratorAuthor
  4. behdad commented on Sep 30, 2019

    @behdad
    Member

    There is no bug. The warning is a false-positive. I'm not sure how to best ignore it. Can remove assertion but don't see why either.

  5. drott commented on Oct 1, 2019

    @drott
    CollaboratorAuthor

    Do you have more info on what Clang fails to find here, and for that purpose could you dissect how the assert is correct? Perhaps we can file a Clang bug.
    CC @nico

  6. drott commented on Oct 1, 2019

    @drott
    CollaboratorAuthor

    Thanks, @ebraminio, good idea.

  7. behdad commented on Oct 7, 2019

    @behdad
    Member

    Do you have more info on what Clang fails to find here, and for that purpose could you dissect how the assert is correct? Perhaps we can file a Clang bug.

    We're asserting that sizeof(backing byte-array) / sizeof(struct) >= number of elements. That's correct calculation. clang is just saying that it looks like we were trying to calculate the number of element in a C array. We are not doing that here.

  8. ebraminio commented on Oct 7, 2019

    @ebraminio
    Collaborator
  9. behdad commented on Oct 8, 2019

    @behdad
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Chrome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions