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

Include <malloc.h> for _alloca #1472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StephanTLavavej
Copy link
Contributor

Recently, I noticed that MSVC's <exception> was unnecessarily dragging in <malloc.h>, and attempted to remove it in microsoft/STL#4626. This revealed a lot of bugs in open-source projects, so I'll probably revert the change (at least for now). However, I thought I'd report this to you, since it's an easy fix.

asio is using _alloca without including <malloc.h> (the proper header as documented on Microsoft Learn), here:

#if defined(BOOST_NO_ANSI_APIS) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
LPWSTR string_buffer = (LPWSTR)_alloca(length * sizeof(WCHAR));

#if defined(BOOST_NO_ANSI_APIS) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
int num_wide_chars = static_cast<int>(strlen(src)) + 1;
LPWSTR wide_buffer = (LPWSTR)_alloca(num_wide_chars * sizeof(WCHAR));

This usage is guarded by #if defined(BOOST_NO_ANSI_APIS) || (defined(_MSC_VER) && (_MSC_VER >= 1800)), but my proposed inclusion is guarded by only #if defined(_MSC_VER) && (_MSC_VER >= 1800) since non-MSVC defined(BOOST_NO_ANSI_APIS) configurations are presumably getting _alloca from somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant