Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter7/runtime_error.rst [] does NOT generate bounds check #54

Open
wrigjl opened this issue Sep 18, 2024 · 0 comments
Open

Chapter7/runtime_error.rst [] does NOT generate bounds check #54

wrigjl opened this issue Sep 18, 2024 · 0 comments

Comments

@wrigjl
Copy link
Collaborator

wrigjl commented Sep 18, 2024

This section talks about how the index operator [] causes runtime errors. It doesn't on any of the compilers I've tested with unless you go way out of your way to make that happen.

The .at() member of string is actually defined to use bounds checking, but the text never mentions it.

Couple of choices here:

  • remove the section
  • switch the chapter to prefer .at()
  • use examples like x[999999] to demonstrate a crash (will require rewriting a bit of the text, too since it claims that str[str.length()] causes a runtime error (it doesn't).
@wrigjl wrigjl changed the title Chapter7/runtime_error.rst Chapter7/runtime_error.rst [] does NOT generate bounds check Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant