tests: Fix specifying constant of double type

Message ID 20241003000408.1355549-1-raj.khem@gmail.com
State Committed
Headers
Series tests: Fix specifying constant of double type |

Commit Message

Khem Raj Oct. 3, 2024, 12:04 a.m. UTC
  'd' suffix seems to be not acceptable by clang compiler
Using 'e0' fixes this by keeping value to be same

Fixes
funcretval_test_struct.c:83:27: error: invalid suffix 'd' on floating constant
   83 |   dpoint_t dp = dmkpt (3.0d, 1.0d);
      |                           ^
funcretval_test_struct.c:83:33: error: invalid suffix 'd' on floating constant
   83 |   dpoint_t dp = dmkpt (3.0d, 1.0d);
      |

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 tests/funcretval_test_struct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Mark Wielaard Oct. 3, 2024, 9:01 a.m. UTC | #1
Hi Khem,

On Wed, Oct 02, 2024 at 05:04:08PM -0700, Khem Raj wrote:
> 'd' suffix seems to be not acceptable by clang compiler

Funny, seems like the d suffix is an undocumented GNU extension that
accidentially slipped in because an early/draft standard said 'd'
stood for double, but that was not in the final standard paper.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84717

> Using 'e0' fixes this by keeping value to be same

We could also have just dropped the suffix (no suffix means a double
constant), since the exact value doesn't really matter in this
testcase. But 'e0' certainly works. So pushed as is.

Thanks,

Mark
  

Patch

diff --git a/tests/funcretval_test_struct.c b/tests/funcretval_test_struct.c
index df94bde0..6bf82f7d 100644
--- a/tests/funcretval_test_struct.c
+++ b/tests/funcretval_test_struct.c
@@ -80,7 +80,7 @@  main (void)
   div_t d = div (3, 2);
   ldiv_t ld = ldiv (3, 2);
   point_t p = mkpt (3.0f, 1.0f);
-  dpoint_t dp = dmkpt (3.0d, 1.0d);
+  dpoint_t dp = dmkpt (3.0e0, 1.0e0);
 
   return d.q - (int) p.y + ld.q - (int) dp.y;
 }