Skip to content
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
6 changes: 6 additions & 0 deletions source/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased

* C++: fixing a regression introduced in 2.9.6.2
- `std::to_string` is not compatible to `--ansi` standard
[[#534](https://github.com/BNFC/bnfc/issues/534)]

# 2.9.6.2

Andreas Abel <andreas.abel@gu.se>, January 2026
Expand Down
14 changes: 12 additions & 2 deletions source/src/BNFC/Backend/C/CFtoBisonC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ header mode cf = unlines $ concat
, when (stlParser mode)
[ "#include <algorithm> /* for std::reverse */" -- mandatory e.g. with GNU C++ 11
, "#include \"" ++ ("ParserError" <.> h) ++ "\"" -- for throwing parser_error in C++

-- Commelina, 2026-03-05, issue #534: @std::to_string@ is invalid with @--ansi@
-- TODO: Choose to use @std::to_string@ or not according to the @--ansi@ flag
, "#include <sstream>"
]
, [ "#include <stdio.h>"
, "#include <stdlib.h>"
Expand Down Expand Up @@ -186,9 +190,15 @@ errorHandler mode = case mode of
, "{"
, " std::string error_msg = msg;"
, " if (loc) {"
, " error_msg += \" at line \" + std::to_string(loc->first_line) +"
, " \", column \" + std::to_string(loc->first_column);"

-- Commelina, 2026-03-05, issue #534: @std::to_string@ is invalid with @--ansi@
-- TODO: Choose to use @std::to_string@ or not according to the @--ansi@ flag
, " std::ostringstream oss;"
, " oss << \" at line \" << loc->first_line"
, " << \", column \" << loc->first_column;"
, " error_msg += oss.str();"
, " }"

, " if (scanner) {"
, " error_msg += \": '\" + std::string(" ++ name ++ "get_text(scanner)) + \"'\";"
, " }"
Expand Down
23 changes: 7 additions & 16 deletions testing/src/ParameterizedTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,11 @@ parameters = concat
-- Functor (Haskell & Agda)
, [ haskellAgdaFunctorParameters]
-- C++ (extras)

-- Note: Disabled on 2026-03-04. Re-enable it after
-- https://github.com/BNFC/bnfc/issues/534 is resolved.
--
-- , [ cBase { tpName = "C++ (with line numbers)"
-- , tpBnfcOptions = ["--cpp", "-l"] }
-- , cBase { tpName = "C++ (with namespace)"
-- , tpBnfcOptions = ["--cpp", "-p foobar"] }
-- ]

, [ cBase { tpName = "C++ (with line numbers)"
, tpBnfcOptions = ["--cpp", "-l"] }
, cBase { tpName = "C++ (with namespace)"
, tpBnfcOptions = ["--cpp", "-p foobar"] }
]
-- C
, [ TP { tpName = "C"
, tpBnfcOptions = ["--c"]
Expand Down Expand Up @@ -433,12 +428,8 @@ parameters = concat
-- C++ (basic)
, [ cBase { tpName = "C++ (no STL)"
, tpBnfcOptions = ["--cpp-nostl"] }

-- Note: Disabled on 2026-03-04. Re-enable it after
-- https://github.com/BNFC/bnfc/issues/534 is resolved.
--
-- , cBase { tpName = "C++"
-- , tpBnfcOptions = ["--cpp"] }
, cBase { tpName = "C++"
, tpBnfcOptions = ["--cpp"] }
]
-- Agda
, [ haskellAgdaParameters ]
Expand Down