Skip to content

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

@wrigjl

Description

@wrigjl

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions