Skip to content

Commit c5a5c9f

Browse files
committed
Upgrade to C++26 and address build errors
1 parent ef08723 commit c5a5c9f

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(CheckCXXSourceCompiles)
55

66
project(python++)
77

8-
set(CMAKE_CXX_STANDARD 23)
8+
set(CMAKE_CXX_STANDARD 26)
99

1010
include(cmake/CPM.cmake)
1111

‎src/executable/bytecode/instructions/Instructions.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,20 @@
7979

8080
using namespace py;
8181

82+
// GCC 16 inlines the std::variant copy-assignment behind py::Value and then
83+
// attributes the std::vector destructor's operator delete to the stack slot
84+
// holding the variant. Nothing is freed here; the diagnostic is a false positive.
85+
#if defined(__GNUC__) && !defined(__clang__)
86+
#pragma GCC diagnostic push
87+
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
88+
#endif
8289
Instruction::RAIIStoreNonCallInstructionData::RAIIStoreNonCallInstructionData()
8390
{
8491
reg0 = VirtualMachine::the().reg(0);
8592
}
93+
#if defined(__GNUC__) && !defined(__clang__)
94+
#pragma GCC diagnostic pop
95+
#endif
8696

8797
Instruction::RAIIStoreNonCallInstructionData::~RAIIStoreNonCallInstructionData()
8898
{

‎src/runtime/PyCell.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ bool PyCell::empty() const
8080

8181
PyResult<PyObject *> PyCell::__repr__() const { return PyString::create(to_string()); }
8282

83+
// GCC 16 inlines the std::variant copy-assignment behind py::Value and then
84+
// attributes the std::vector destructor's operator delete to the stack slot
85+
// holding the variant. Nothing is freed here; the diagnostic is a false positive.
86+
#if defined(__GNUC__) && !defined(__clang__)
87+
#pragma GCC diagnostic push
88+
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
89+
#endif
8390
void PyCell::set_cell(const Value &new_value) { m_content = new_value; }
91+
#if defined(__GNUC__) && !defined(__clang__)
92+
#pragma GCC diagnostic pop
93+
#endif
8494

8595
namespace {
8696
std::once_flag cell_flag;

‎src/runtime/modules/PosixModule.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string_view>
1818

1919
#include <sys/stat.h>
20+
#include <unistd.h>
2021

2122
namespace fs = std::filesystem;
2223

‎src/runtime/modules/SysModule.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PyResult<PyList *> create_sys_paths(Interpreter &interpreter)
4040
const auto &entry_script = interpreter.entry_script();
4141
auto entry_parent = PyString::create(std::filesystem::path(entry_script).parent_path());
4242
if (entry_parent.is_err()) return Err(entry_parent.unwrap_err());
43-
auto path_list = PyList::create({
43+
auto path_list = PyList::create(std::vector<Value>{
4444
entry_parent.unwrap(),
4545
PyString::create(kPythonLibPath.data()).unwrap(),
4646
});

0 commit comments

Comments
 (0)