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 build issues with clang18 #94782

Merged
merged 5 commits into from
Nov 16, 2023
Merged
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
5 changes: 5 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ if (CLR_CMAKE_HOST_UNIX)
add_compile_options(-Wimplicit-fallthrough)
endif()

# VLAs are non standard in C++, aren't available on Windows and
# are a warning by default since clang 18.
# For consistency, enable warnings for all compiler versions.
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wvla>)

#These seem to indicate real issues
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ bool GCToOSInterface::VirtualCommit(void* address, size_t size, uint16_t node)
if ((int)node <= g_highestNumaNode)
{
int usedNodeMaskBits = g_highestNumaNode + 1;
int nodeMaskLength = (usedNodeMaskBits + sizeof(unsigned long) - 1) / sizeof(unsigned long);
unsigned long nodeMask[nodeMaskLength];
memset(nodeMask, 0, sizeof(nodeMask));
int nodeMaskLength = usedNodeMaskBits + sizeof(unsigned long) - 1;
unsigned long* nodeMask = (unsigned long*)alloca(nodeMaskLength);
memset(nodeMask, 0, nodeMaskLength);

int index = node / sizeof(unsigned long);
nodeMask[index] = ((unsigned long)1) << (node & (sizeof(unsigned long) - 1));
Expand Down Expand Up @@ -1189,10 +1189,10 @@ uint64_t GetAvailablePhysicalMemory()
#elif defined(__FreeBSD__)
size_t inactive_count = 0, laundry_count = 0, free_count = 0;
size_t sz = sizeof(inactive_count);
sysctlbyname("vm.stats.vm.v_inactive_count", &inactive_count, &sz, NULL, 0);
sysctlbyname("vm.stats.vm.v_inactive_count", &inactive_count, &sz, NULL, 0);

sz = sizeof(laundry_count);
sysctlbyname("vm.stats.vm.v_laundry_count", &laundry_count, &sz, NULL, 0);
sysctlbyname("vm.stats.vm.v_laundry_count", &laundry_count, &sz, NULL, 0);

sz = sizeof(free_count);
sysctlbyname("vm.stats.vm.v_free_count", &free_count, &sz, NULL, 0);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/pal/src/file/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ GetTempPathW(
return 0;
}

char TempBuffer[nBufferLength > 0 ? nBufferLength : 1];
DWORD dwRetVal = GetTempPathA( nBufferLength, TempBuffer );
char* tempBuffer = (char*)alloca(nBufferLength > 0 ? nBufferLength : 1);
DWORD dwRetVal = GetTempPathA( nBufferLength, tempBuffer );

if ( dwRetVal >= nBufferLength )
{
Expand All @@ -411,7 +411,7 @@ GetTempPathW(
else if ( dwRetVal != 0 )
{
/* Convert to wide. */
if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1,
if ( 0 == MultiByteToWideChar( CP_ACP, 0, tempBuffer, -1,
lpBuffer, dwRetVal + 1 ) )
{
ASSERT( "An error occurred while converting the string to wide.\n" );
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/pal/src/include/pal/palinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ function_name() to call the system's implementation
#undef va_start
#undef va_end
#undef va_copy
#undef va_arg
#undef stdin
#undef stdout
#undef stderr
Expand Down
2 changes: 1 addition & 1 deletion src/native/minipal/getexepath.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static inline char* minipal_getexepath(void)
return NULL;
}

char path_buf[path_length];
char* path_buf = (char*)alloca(path_length);
if (_NSGetExecutablePath(path_buf, &path_length) != 0)
{
errno = EINVAL;
Expand Down
Loading