这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@mtl1979
Copy link
Collaborator

@mtl1979 mtl1979 commented Aug 12, 2024

Level 4 warning C4242 is 'identifier': conversion from 'type1' to 'type2', possible loss of data, which is usually result of missing truncating cast or incorrect type used in cast or expression.

See discussion in #1762. Rationale for treating warnings as errors is that most developers use Linux or other Unix-compatible systems and only small fraction have Windows to test any changes.

@codecov
Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.03%. Comparing base (3da40c2) to head (72b5a47).
Report is 1 commits behind head on develop.

Files Patch % Lines
test/fuzz/fuzzer_minigzip.c 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1768   +/-   ##
========================================
  Coverage    83.03%   83.03%           
========================================
  Files          135      135           
  Lines        10304    10310    +6     
  Branches      2784     2785    +1     
========================================
+ Hits          8556     8561    +5     
+ Misses        1055     1054    -1     
- Partials       693      695    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtl1979 mtl1979 force-pushed the msvc-warn branch 7 times, most recently from b77611c to 9875a8b Compare August 16, 2024 15:01
@mtl1979 mtl1979 force-pushed the msvc-warn branch 2 times, most recently from bc00bd8 to 4a776c8 Compare August 16, 2024 17:28
@mtl1979 mtl1979 requested a review from nmoinvaz August 16, 2024 18:05
@mtl1979 mtl1979 force-pushed the msvc-warn branch 5 times, most recently from fb1f0b4 to d2afadc Compare August 16, 2024 20:43
@mtl1979 mtl1979 marked this pull request as draft August 16, 2024 22:39
@mtl1979 mtl1979 marked this pull request as ready for review August 17, 2024 01:02
Comment on lines +8 to +14
#if defined(_MSC_VER) && !defined(_MM_K0_REG8)
# undef _mm512_extracti64x4_epi64
# define _mm512_extracti64x4_epi64(v1, e1) _mm512_maskz_extracti64x4_epi64(UINT8_MAX, v1, e1)
# undef _mm512_set1_epi16
# define _mm512_set1_epi16(e1) _mm512_maskz_set1_epi16(UINT32_MAX, e1)
# undef _mm512_maddubs_epi16
# define _mm512_maddubs_epi16(v1, v2) _mm512_maskz_maddubs_epi16(UINT32_MAX, v1, v2)
Copy link
Contributor

@KungFuJesus KungFuJesus Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this actually a bad definition in their intrinsic that causes a partial mask, or is this just something silly like Microsoft defines this as a macro with -1 as the mask (which is technically correct but an overly pedantic compiler might try to complain about it)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KungFuJesus Microsoft forgot to define the mask for half of the variants, and instead used mask for twice the big bit width and assumed their own compiler will truncate it without warning. So basically there was only _MM_K0_REG16 and _MM_K0_REG64 defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, so it sounds like they weren't quite anticipating AVX512BW and just dropped in the 16 bit masks instead. Which still result in correct behavior, but the implicit truncation causes their pedantic warnings to trigger. It is still silly but I guess functionally this is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KungFuJesus Microsoft likes to do things their own way and not copy how others have done the same thing... I don't think they anticipated that developers start to use higher warning levels than 3 on production code or that developers want to treat all warnings as errors, even though they anticipated that developers want to silence some warnings or to move some warnings to different level.

#endif // defined(_MSC_VER) && _MSC_VER < 1914

/* Visual C++ toolchains before v142 have constant overflow in AVX512 intrinsics */
#if defined(_MSC_VER) && defined(__AVX512F__) && !defined(_MM_K0_REG8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the most reliable preprocessor definition for this (_MM_K0_REG8)? Shouldn't we use an MSC_VER comparison?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_MSC_VER doesn't show the toolchain or SDK version, only the IDE version... In this case it was using Visual C++ 2019 frontend, but the toolchain was from Visual C++ 2015 (v140) or Visual C++ 2017 (v141), so the used SDK (headers) was broken.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah and given the context above I say this should be fine. Basically, they don't have the 8 bit mask registers defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really didn't want to diff all the available SDK versions to see if there is a header that defines the SDK version and which SDK version did fix each of the broken intrinsic macros... Making such complex tests would have warranted extensive commenting and might have slowed down preprocessing and compiling the code by quite a lot.

Copy link
Contributor

@KungFuJesus KungFuJesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dead2 Dead2 merged commit 5b04d9c into zlib-ng:develop Aug 22, 2024
This was referenced Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants