diff options
| author | YongDo-Hyun <froster12@naver.com> | 2025-12-27 01:16:53 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-03-27 19:57:09 +0300 |
| commit | 7c9c42329e453c0c1e70ec37efcf5375065b3567 (patch) | |
| tree | 59e8567fc5cb9eec85abe19590119f9802b7b8db /src/value.cpp | |
| parent | df0519bea5390ac8f3d9a0e168e2f799bd068985 (diff) | |
| download | Project-Tick-7c9c42329e453c0c1e70ec37efcf5375065b3567.tar.gz Project-Tick-7c9c42329e453c0c1e70ec37efcf5375065b3567.zip | |
fix: prevent widening of stored tag type in value assignment; update test output handling
Signed-off-by: YongDo-Hyun <froster12@naver.com>
Diffstat (limited to 'src/value.cpp')
| -rw-r--r-- | src/value.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/value.cpp b/src/value.cpp index 273049baf9..f07e28d82c 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -98,17 +98,12 @@ namespace // helper functions local to this translation unit auto incoming_type = detail::get_primitive_type<T>::value; // If the existing tag is of a narrower type than the incoming type, - // replace it with a new tag of the incoming type so the value is not - // truncated. Otherwise set the existing tag (possibly narrowing). + // reject the assignment to avoid widening the stored tag type. auto existing_type = tag_ptr->get_type(); if(static_cast<int>(existing_type) < static_cast<int>(incoming_type)) { - // replace with a new, wider tag that preserves the value - tag_ptr = make_numeric_tag(incoming_type, val); - if(!tag_ptr) - throw std::bad_cast(); - return; + throw std::bad_cast(); } // Existing type is same or wider: write into the existing tag (may narrow) |
