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

オープン
#65 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
cpp
領域
compilers

調査の方向性

Godbolt の再現コードと boost/preprocessor/punctuation/remove_parens.hpp から始めて、BOOST_PP_REMOVE_PARENS が入力をどのように処理するかを確認します。文書化された契約を見直し、互換性と命名への影響を含め、意図する API 変更を決定します。明示的に決定された契約に動作とドキュメントが一致し、再現コードで報告された問題点がもはや露呈しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

#include <boost/preprocessor/punctuation/remove_parens.hpp>

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

"Parenthesis" is singular (plural is parentheses), 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.

主要言語
C++
スター
118
フォーク
76
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/preprocessor のほかの issue

boostorg/preprocessor の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。