Allow overrides for std::terminate
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- embedded-iot
Línea de trabajo
Start in include/cetl/cetl.hpp and copy the existing CETL_DEBUG_ASSERT override pattern, then replace the std::terminate() calls in the five listed headers (optional.hpp line 761, variant.hpp line 227, string_view.hpp 137/244/261, unbounded_variant.hpp 70, pmr/function.hpp 78) inside their !defined(__cpp_exceptions) branches with CETL_TERMINATE(). Read CETL_DEBUG_ASSERT and any docs that describe it to match wording, and drop the now-unneeded <exception> includes from headers that only pulled it in for std::terminate. Done looks like: defining CETL_TERMINATE() to a trap before inclusion makes the library build with -fno-exceptions on a target without libsupc++, and the default still resolves to std::terminate().
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
With -fno-exceptions, CETL's bad-access paths call std::terminate(). On targets that link no C++ runtime library (no libsupc++; for example NuttX-based flight controllers), std::terminate does not exist, so any code that can reach these paths fails to link. Please provide a way for the user to supply a platform-specific termination routine that CETL calls instead of std::terminate() when exceptions are disabled.
Where (main @ bf1e5f3)
| File | Line | Path |
|---|---|---|
include/cetl/pf17/optional.hpp |
761 | ensure_engaged() (value()) |
include/cetl/pf17/variant.hpp |
227 | bad_access_unless() (get, visit) |
include/cetl/pf17/string_view.hpp |
137, 244, 261 | out-of-range access |
include/cetl/unbounded_variant.hpp |
70 | bad access |
include/cetl/pmr/function.hpp |
78 | bad call |
Proposal
A single overridable macro in cetl/cetl.hpp, following the existing CETL_DEBUG_ASSERT pattern:
/// @def CETL_TERMINATE
/// Called instead of throwing when exceptions are disabled. Must not return.
/// Define it before including any CETL header to route to a platform handler,
/// e.g. `#define CETL_TERMINATE() ::abort()` or a board-specific panic.
#ifndef CETL_TERMINATE
# include <exception>
# define CETL_TERMINATE() std::terminate()
#endif
All of the sites above would call CETL_TERMINATE() in their !defined(__cpp_exceptions) branches. That also lets the headers include <exception> only when the default is used. Several currently include it unconditionally "for std::terminate", which matters for builds that avoid C++ runtime headers.
Notes:
- A macro (rather than a weak function) works for header-only use and avoids defining any symbol in
namespace std. - Documenting that the handler must be
[[noreturn]]and must not throw would let CETL keep itsnoexceptguarantees. - The upcoming
expectedpolyfill's bad-access path (value()on an error) would naturally use the same hook. - A CI configuration that defines
CETL_TERMINATE()as__builtin_trap()and checks that objects reference nostd::terminatewould catch regressions.
- Lenguaje dominante
- C++
- Estrellas
- 18
- Forks
- 4
- Merge medio
- 7 d 16 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenCyphal/CETL
-
accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OpenCyphal/CETL#271 ·
-
documentation
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
OpenCyphal/CETL#262 ·
-
under consideration
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
OpenCyphal/CETL#252 ·
-
tracking
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
OpenCyphal/CETL#194 ·
-
under consideration
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
OpenCyphal/CETL#176 · 1 comentario ·
Todos los issues de OpenCyphal/CETL
Issues similares
-
good first issue hardware-report help wanted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
launcher: settings are never saved on macOS — QSettings SystemScope points to /Library/PreferencesAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
documentation ready
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
MartinPTielemans/ilo#3806 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100