boostorg / boostorg/preprocessor

BOOST_PP_REMOVE_PARENS() is dangerously broken -- it strips initial group of parentheses instead of surrounding

Abierto
#65 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
118
Forks
76
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

https://godbolt.org/z/38jbTP7qn

```
#include

int main(int argc, char *argv[]) {
#if MACRO
return BOOST_PP_REMOVE_PARENS((*argv)[1]); // Crash
#else
return (*argv)[1] ; // OK
#endif
}
```

Note the documentation piles extra confusion on top of this. It says:

> The `BOOST_PP_REMOVE_PARENS` macro removes the beginning parenthesis, if it exists, from the input data and expands to the result

"Parenthes**i**s" is singular (plural is parenthes**es**), so the documentation is claiming that only a beginning `(` is being removed. It makes no mention of removing any closing `)`, regardless of its expected location, even though the function apparently does that regardless of its location.

This is a massive pitfall. The name `BOOST_PP_REMOVE_PARENS` itself (and the intended usage) are misleading for most users and very unlikely to be what they actually want.

I would suggest, at the very least, renaming the macro to something like `BOOST_PP_REMOVE_BEGINNING_PARENS` and updating the documentation to clarify it is not doing what users would expect from a `REMOVE_PARENS` macro.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start with the Godbolt reproducer and boost/preprocessor/punctuation/remove_parens.hpp to verify how BOOST_PP_REMOVE_PARENS handles the input. Review the documented contract and determine the intended API change, including compatibility and naming implications. Done means the behavior and documentation agree with an explicitly decided contract, with the reproducer no longer exposing the reported pitfall.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp
Área
compilers
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.