-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Dart Info
- Dart 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"
- on macos / Version 14.5 (Build 23F79)
- locale is en-US
I'm writing a Flutter app and noticed a difference in dart SDK behavior between Debug and Release builds, so I investigated with a pure dart example:
import 'dart:typed_data';
void main(List<String> arguments) {
try {
List<int> output = [];
ByteData bytes = Uint8List.fromList(output).buffer.asByteData();
final _ = bytes.getInt64(0);
print('caught nothing!');
} catch (e) {
print('caught $e!');
}
}
If I use dart run, this correctly throws an IndexError:
caught RangeError (byteOffset): Index out of range: index should be less than -7: 0!
If I first compile it as an exe dart compile exe bin/test_app.dart -o test_app, then the app happily runs without throwing anything:
caught nothing!
Is this an intentional optimization in the SDK? If so, what's the mechanism that determines whether or not throws are discarded during compilation? I've noticed that other throws within the class survive the compilation, but not the ones for these accessors.
kenfred, julemand101 and Levi-Lesches
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)