Pointer arithmetic demo accesses out-of-bounds memory without warning (Ch 30 / 00.pointers.ipynb)
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- cpp, jupyter-notebook
調査の方向性
30.pointers-and-memory-management/00.pointers.ipynb を開き、セル 16 の int_ptr.cpp の例を確認してください。単一の int を使ったセットアップを、issue で説明されている有効な配列ベースの例に置き換え、その後、表示されるポインター算術の出力が範囲外のメモリをデリファレンスしなくなっていることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
In 30.pointers-and-memory-management/00.pointers.ipynb, the int_ptr.cpp example (cell 16) declares a single int i = 0; and then performs pointer arithmetic that dereferences memory past i:
int i = 0;
int *p = &i;
// ...
cout << "*(p + 1) = " << ... << *(p + 1) << '\n'; // dereferencing OOB
cout << "*(p + 2) = " << ... << *(p + 2) << '\n'; // dereferencing OOB
This is undefined behavior. The C++ standard permits p+1 (one-past-the-end pointer arithmetic) but explicitly forbids dereferencing it when p doesn't point into an array. The demo "works" because the runtime happens to allow reading adjacent stack memory, but the output is shown to students as if it were a normal pattern to learn from — which risks teaching the wrong mental model.
Suggested fix (preferred: option 1)
Option 1 — make the example valid by using an actual array:
int arr[3] = {0, 1, 2};
int *p = arr;
// (p+1) and (p+2) are now valid dereferences into arr[1] and arr[2]
Option 2 — keep the example but add a markdown cell explicitly noting this is UB, and that the output happens to read adjacent stack memory (sometimes &p and parts of the stack frame).
Option 1 is cleaner for a teaching context: students see correct pointer arithmetic without needing the UB sidebar.
Context
Surfaced during Ch 30 evaluation. Small isolated change; pairs well with the delete[] bug fix as another "first commit" candidate.
- 主要言語
- Jupyter Notebook
- スター
- 3
- フォーク
- 1
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
kangwonlee/2018pycpp のほかの issue
-
enhancement freshman-audience
難易度 3/5 1〜3時間 初心者へのやさしさ 68/100
kangwonlee/2018pycpp#76 ·
-
Intel assemblyオープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
kangwonlee/2018pycpp#65 ·
-
CI in tutorial gitオープンenhancement
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
kangwonlee/2018pycpp#61 ·
-
Rust studyオープン
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
kangwonlee/2018pycpp#56 · コメント 1 件 ·
-
question
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
kangwonlee/2018pycpp#52 ·
kangwonlee/2018pycpp の issue をすべて見る
似ている issue
-
good first issue hacktoberfest
難易度 2/5 半日 初心者へのやさしさ 70/100
HelpCode-ai/anythingmcp#996 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
zerocracy/judges-action#2730 ·
メンテナーはふだん 8 日以内に返信
-
feedback simulation workshop
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
githubnext/gh-aw-workshop#4417 ·
メンテナーはふだん 1 日以内に返信
-
documentation Good First Issue hacktoberfest Non-Code
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
hiero-ledger/hiero-sdk-js#4488 ·
メンテナーはふだん 1 日以内に返信
-
enhancement low-priority milestone-qa tests
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
lognorman20/monaco#4858 ·