Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paltests build #103519

Merged
merged 4 commits into from
Jun 15, 2024
Merged

Fix paltests build #103519

merged 4 commits into from
Jun 15, 2024

Conversation

am11
Copy link
Member

@am11 am11 commented Jun 15, 2024

https://dev.azure.com/dnceng-public/public/_build/results?buildId=708804&view=logs&jobId=a3b522d2-1fcb-58aa-d1da-345566122d64&j=a3b522d2-1fcb-58aa-d1da-345566122d64&t=28177cd9-7046-57c0-17a4-2d126beee140

/__w/1/s/build.sh -ci -arch arm64 -os linux -cross -s clr.paltests+clr.paltestlist      
...
  [ 70%] Building CXX object pal/tests/palsuite/CMakeFiles/paltests.dir/file_io/ReadFile/test3/ReadFile.cpp.o
  /__w/1/s/src/coreclr/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp:132:29: error: non-constant-expression cannot be narrowed from type 'size_t' (aka 'unsigned long') to 'DWORD' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
    132 |                             strlen(szStringTest),
        |                             ^~~~~~~~~~~~~~~~~~~~
  /__w/1/s/src/coreclr/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp:132:29: note: insert an explicit cast to silence this issue
    132 |                             strlen(szStringTest),
        |                             ^~~~~~~~~~~~~~~~~~~~
        |                             static_cast<DWORD>( )
  /__w/1/s/src/coreclr/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp:133:29: error: non-constant-expression cannot be narrowed from type 'long' to 'DWORD' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
    133 |                             pageSize
        |                             ^~~~~~~~
  /__w/1/s/src/coreclr/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp:133:29: note: insert an explicit cast to silence this issue
    133 |                             pageSize
        |                             ^~~~~~~~
        |                             static_cast<DWORD>( )
  [ 70%] Building CXX object pal/tests/palsuite/CMakeFiles/paltests.dir/file_io/ReadFile/test4/readfile.cpp.o
  2 errors generated.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 15, 2024
@@ -61,8 +61,8 @@ PALTEST(file_io_WriteFile_test2_paltest_writefile_test2, "file_io/WriteFile/test
const char * testString = "The quick fox jumped over the lazy dog's back.";
const int testStringLen = strlen(testString);
Copy link
Member

Choose a reason for hiding this comment

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

Should this implicit size_t -> int cast be made explicit as well? It is interesting that the compiler is not complaining about this strlen("constant string"), but it is complaining about the other strlen("constant string").

Copy link
Member Author

Choose a reason for hiding this comment

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

Declaring it as DWORD also works without the explicit cast.

Copy link
Member

Choose a reason for hiding this comment

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

I would not depend on it. In general, compilers complain about any implicit narrowing these days.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@jkotas jkotas merged commit 4834a50 into dotnet:main Jun 15, 2024
86 of 89 checks passed
@am11 am11 deleted the feature/build/pal.tests branch June 15, 2024 19:27
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-PAL-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants