Skip to content
Snippets Groups Projects
Commit 1f5360a3 authored by Yen-Chen Chen's avatar Yen-Chen Chen
Browse files

Fix unsafe type conversion (!74)

<!--
ICON

---------------------------------------------------------------
Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Contact information: icon-model.org

See AUTHORS.TXT for a list of authors
See LICENSES/ for license information
SPDX-License-Identifier: CC0-1.0
---------------------------------------------------------------
-->

## What is the bug
The way of type conversion [here](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/blame/55913610ae02141850eb92c2ccc3f58759344646/src/mo_expression.F90?page=2#L1073

) is not suggested.
## How do you fix it
Convert types specifically. 

## How urgent is the bugfix
- [x] I need it as soon as possible
- [ ] I can wait for a couple of days
- [ ] None of my current codes is directly affected

## Mandatory steps before review
- [ ] Gitlab CI passes _(Hint: use `make format` for linting)_ 
- [x] Bugfix is covered by additional unit tests
- [x] Mark the merge request as ready by removing `Draft:`

## Mandatory steps before merge
- [ ] Test coverage does not decrease
- [ ] Reviewed by a maintainer
- [ ] Incorporate review suggestions
- [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)

**You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**

Co-authored-by: default avatarMarek Jacob <1129-b380572@users.noreply.gitlab.dkrz.de>
Approved-by: default avatarMarek Jacob <1129-b380572@users.noreply.gitlab.dkrz.de>
Merged-by: default avatarYen-Chen Chen <yen-chen.chen@kit.edu>
Changelog: bugfix
parent 110e6e43
No related branches found
No related tags found
1 merge request!74Fix unsafe type conversion
Pipeline #61443 passed
......@@ -1053,8 +1053,8 @@ CONTAINS
INTEGER :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (arg2 == exponent) THEN
exponent = NINT(arg2)
IF (arg2 == REAL(exponent, real_kind)) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......@@ -1070,8 +1070,8 @@ CONTAINS
INTEGER, DIMENSION(:, :), ALLOCATABLE :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (ALL(arg2 == exponent)) THEN
exponent = NINT(arg2)
IF (ALL(arg2 == REAL(exponent, real_kind))) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......@@ -1087,8 +1087,8 @@ CONTAINS
INTEGER, DIMENSION(:, :, :), ALLOCATABLE :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (ALL(arg2 == exponent)) THEN
exponent = NINT(arg2)
IF (ALL(arg2 == REAL(exponent, real_kind))) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment