[MDEV-20427] conversion of LONGLONG_MAX to double and back to long long results in LONGLONG_MIN Created: 2019-08-26  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Data types, Server
Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Eugene Kosov (Inactive) Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Here are funny casts https://godbolt.org/z/K6Rvnc

It could happen here https://github.com/mariadb/server/blob/10.1/sql/sql_time.cc#L406 and here https://github.com/mariadb/server/blob/10.1/include/my_time.h#L122

I wasn't able to write a test and found these bugs by reading the code.



 Comments   
Comment by Sergei Golubchik [ 2019-08-28 ]

Had it just a few days ago in EXPLAIN, see https://github.com/mariadb/server/commit/4f321289af20427d59aa7c46da

(ulonglong)(double)~0ULL was 0 on Linux/gcc and -9223372036854775808 on Windows/VS2019

Generated at Thu Feb 08 08:59:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.