Skip to content

8324686: Remove redefinition of NULL for MSVC #24537

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/hotspot/share/utilities/globalDefinitions_visCPP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,6 @@
#error unsupported platform
#endif

// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
// system header files. On 32-bit architectures, there is no problem.
// On 64-bit architectures, defining NULL as a 32-bit constant can cause
// problems with varargs functions: C++ integral promotion rules say for
// varargs, we pass the argument 0 as an int. So, if NULL was passed to a
// varargs function it will remain 32-bits. Depending on the calling
// convention of the machine, if the argument is passed on the stack then
// only 32-bits of the "NULL" pointer may be initialized to zero. The
// other 32-bits will be garbage. If the varargs function is expecting a
// pointer when it extracts the argument, then we may have a problem.
//
// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
#undef NULL
// 64-bit Windows uses a P64 data model (not LP64, although we define _LP64)
// Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific
// 64-bit integer-suffix (LL) instead.
#define NULL 0LL

typedef int64_t ssize_t;

// Non-standard stdlib-like stuff:
Expand Down
3 changes: 1 addition & 2 deletions test/hotspot/jtreg/sources/TestNoNULL.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public static void main(String[] args) throws IOException {
private static void initializeExcludedPaths(Path rootDir) {
List<String> sourceExclusions = List.of(
"src/hotspot/share/prims/jvmti.xml",
"src/hotspot/share/prims/jvmti.xsl",
"src/hotspot/share/utilities/globalDefinitions_visCPP.hpp"
"src/hotspot/share/prims/jvmti.xsl"
);

List<String> testExclusions = List.of(
Expand Down