-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[portable-snippets] Fix array length issue #35791
Conversation
This problem has been submitted to the upstream issue 48 for feedback, but there was no reply from the upstream for a long time, so I tried to fix it in vcpkg. |
This is not true: Variable Length Arrays (VLAs) exist. GCC implements them and I believe Clang implements them for compatibility with GCC, MSVC does not implement them. My understanding is that that feature is widely considered to be a mistake, but it's been in there since 1999. Are there necessary ci.baseline.txt changes or something? (Why is this not causing the current builds to fail?) |
#endif | ||
|
||
-static int (* psnip_random_secure_generate)(size_t length, psnip_uint8_t data[PSNIP_RANDOM_ARRAY_PARAM(length)]) = NULL; | ||
+static int (* psnip_random_secure_generate)(size_t length, psnip_uint8_t *data) = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PSNIP_RANDOM_ARRAY_PARAM
is defined in the header. Can't it choose a supported definition?
The default definition us empty, i.e.
static int (* psnip_random_secure_generate)(size_t length, psnip_uint8_t data[]) = NULL;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After adding the C11 option, the default options were not entered and a compilation error occurred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you could simply add a single && !defined(_MSC_VER)
to the condition before the second definition alternative for PSNIP_RANDOM_ARRAY_PARAM
. Like it already excludes __PGI
.
This is an issue of VCPKG testing MSVC.
This problem is due to the lack of compilation option -std:c11, after adding this option, a new problem has appeared.
|
My point is, don't there need to be ci.baseline.txt or similar changes? If MSVC hates it why aren't we seeing it failing in CI builds? |
https://dev.azure.com/vcpkg/public/_build/results?buildId=97842 Installing 1740/2229 portable-snippets:x64-windows@2019-09-20#3...
Building portable-snippets:x64-windows@2019-09-20#3...
-- Note: portable-snippets only supports static library linkage. Building static library.
-- Downloading https://github.com/nemequ/portable-snippets/archive/26496acb37ab46ee249ea19d45381da6955d89c4.tar.gz -> nemequ-portable-snippets-26496acb37ab46ee249ea19d45381da6955d89c4.tar.gz...
-- Extracting source D:/downloads/nemequ-portable-snippets-26496acb37ab46ee249ea19d45381da6955d89c4.tar.gz
-- Using source at D:/b/portable-snippets/src/a6955d89c4-b026d6ec08.clean
-- Found external ninja('1.11.0').
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Performing post-build validation
Stored binaries in 1 destinations in 94.7 ms.
Elapsed time to handle portable-snippets:x64-windows: 2.1 s Is the frontend team aware that they regressed this? I don't object to merging this but this seems like the kind of regression our testing is supposed to catch, not paper over. |
This looks like a compiler bug to me. #if defined(HEDLEY_ARRAY_PARAM)
# define PSNIP_RANDOM_ARRAY_PARAM(expr) HEDLEY_ARRAY_PARAM(expr)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) && !defined(__PGI)
# define PSNIP_RANDOM_ARRAY_PARAM(expr) (expr)
#else
# define PSNIP_RANDOM_ARRAY_PARAM(expr)
#endif which means that without static int (* psnip_random_secure_generate)(size_t length, psnip_uint8_t data[PSNIP_RANDOM_ARRAY_PARAM(length)]) = NULL; should expand to static int (* psnip_random_secure_generate)(size_t length, psnip_uint8_t data[]) = NULL; which is valid. The compiler appears wrong to treat a macro expanding to no tokens as a constant zero.
Has a compiler frontend dev seen this? |
There is a related issue 1250747 with compiler development, but this issue has not been fixed yet. Do we need to wait for the compiler developers to fix this? |
That seems unrelated since there is no |
I believe the correct fix is nemequ/portable-snippets#50 |
OK, I'll fix it and test it. |
Duplicate of #36143. |
The function
psnip_random_bytes
in the header filerandom.h
defines the arraydata[PSNIP_RANDOM_ARRAY_PARAM(length)]
. However, the size of this array is a variable. C language requires that the size of the array be a constant during compilation, so the compilation fails.So the incoming array will be modified by the incoming pointer.
SHA512s are updated for each updated downloadThe "supports" clause reflects platforms that may be fixed by this new versionAny fixed CI baseline entries are removed from that file.Any patches that are no longer applied are deleted from the port's directory../vcpkg x-add-version --all
and committing the result.Usage test pass with following triplets: