Skip to content

Conversation

@felixf4xu
Copy link

@felixf4xu felixf4xu commented Jun 12, 2024

Hi,

When I build this project (with gcc 14) for this code:

void foonathan::memory::virtual_memory_release(void* pages, std::size_t) noexcept
{
auto result = VirtualFree(pages, 0u, MEM_RELEASE);
FOONATHAN_MEMORY_ASSERT_MSG(result, "cannot release pages");
}

I had this error:

src/virtual_memory.cpp: In function 'void foonathan::memory::virtual_memory_release(void*, std::size_t)':
src/virtual_memory.cpp:50:10: error: unused variable 'result' [-Werror=unused-variable]
50 | auto result = VirtualFree(pages, 0u, MEM_RELEASE);
| ^~~~~~

it happens when FOONATHAN_MEMORY_DEBUG_ASSERT is not defined and then FOONATHAN_MEMORY_ASSERT_MSG is an empty macro and then result is not used.

This PR is to fix the compiling error.

Fix #183

Signed-off-by: U-CW01\uig08771 <uig08771@HIL4255W.cw01.contiwan.com>
@chinanewer
Copy link
Contributor

The same problem also exists in another place, as shown below:

void foonathan::memory::virtual_memory_decommit(void* memory, std::size_t no_pages) noexcept
{
    auto result = VirtualFree(memory, no_pages * virtual_memory_page_size, MEM_DECOMMIT);
    FOONATHAN_MEMORY_ASSERT_MSG(result, "cannot decommit memory");
}

I fix on pull-189.

@foonathan
Copy link
Owner

Thanks for the PR, I went with the approach from #189. And sorry for the delay.

@foonathan foonathan closed this May 2, 2025
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.

compiler error ( from warning) when compiled with FOONATHAN_MEMORY_DEBUG_ASSERT and FOONATHAN_MEMORY_ASSERT not defined

3 participants