Two translation units use standard-library facilities whose headers are never included, relying instead on whatever <iostream> / <string> / <vector> happen to pull in transitively on the current toolchain.
src/grid.cpp throws std::runtime_error (lines 30 and 116) and calls rand() (line 120). Its only includes are header/grid.h and <iostream> (lines 1 and 3); grid.h adds <iostream>, <vector>, and location.h → entity.h → <string>. <stdexcept> and <cstdlib> are never included on that path.
src/environment.cpp throws std::runtime_error (lines 67 and 86) and catches it (line 141). It includes <stdlib.h> (so rand() on line 113 is covered) and <iostream>, but not <stdexcept>.
The build succeeds today because libstdc++'s <iostream> and <string> transitively include <stdexcept>, and <iostream> reaches <cstdlib>. That is an implementation detail, not a guarantee: a different standard library (libc++, MSVC's STL) or a future libstdc++ header cleanup can drop the transitive include, at which point the library stops compiling with 'runtime_error' is not a member of 'std' even though nothing in the project changed.
Suggested fix: add #include <stdexcept> and #include <cstdlib> to src/grid.cpp, and #include <stdexcept> to src/environment.cpp (optionally replacing <stdlib.h> with <cstdlib> there for consistency, though that is cosmetic). No behaviour changes; the acceptance criterion is that make still builds cleanly and bash run_tests.sh still passes.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
Two translation units use standard-library facilities whose headers are never included, relying instead on whatever
<iostream>/<string>/<vector>happen to pull in transitively on the current toolchain.src/grid.cppthrowsstd::runtime_error(lines 30 and 116) and callsrand()(line 120). Its only includes areheader/grid.hand<iostream>(lines 1 and 3);grid.hadds<iostream>,<vector>, andlocation.h→entity.h→<string>.<stdexcept>and<cstdlib>are never included on that path.src/environment.cppthrowsstd::runtime_error(lines 67 and 86) and catches it (line 141). It includes<stdlib.h>(sorand()on line 113 is covered) and<iostream>, but not<stdexcept>.The build succeeds today because libstdc++'s
<iostream>and<string>transitively include<stdexcept>, and<iostream>reaches<cstdlib>. That is an implementation detail, not a guarantee: a different standard library (libc++, MSVC's STL) or a future libstdc++ header cleanup can drop the transitive include, at which point the library stops compiling with'runtime_error' is not a member of 'std'even though nothing in the project changed.Suggested fix: add
#include <stdexcept>and#include <cstdlib>tosrc/grid.cpp, and#include <stdexcept>tosrc/environment.cpp(optionally replacing<stdlib.h>with<cstdlib>there for consistency, though that is cosmetic). No behaviour changes; the acceptance criterion is thatmakestill builds cleanly andbash run_tests.shstill passes.This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson