[scc-dev] [PATCH] tests/cc: Fix 0225-func.c pointer type

From: Michael Forney <mforney_at_mforney.org>
Date: Sat, 13 Apr 2024 12:51:44 -0700

According to C99 6.4.2.2p1, __func__ is declared as array of const
char, so when used as an initializer, it is converted to const char *.

An initializer for a scalar follows the same type constraints as
simple assignment, which for pointers requires that both are to
compatible types, and char and const char are not compatible since
the have different qualifiers.
---
 tests/cc/execute/0225-func.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/cc/execute/0225-func.c b/tests/cc/execute/0225-func.c
index 823866d6..698e2ef3 100644
--- a/tests/cc/execute/0225-func.c
+++ b/tests/cc/execute/0225-func.c
_at_@ -1,7 +1,7 @@
 int
 main(void)
 {
-	char *p = __func__;
+	const char *p = __func__;
 	int i;
 
 	for (i = 0; i < sizeof(__func__); i++) {
-- 
2.44.0
--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Sat 13 Apr 2024 - 21:51:44 CEST

This archive was generated by hypermail 2.3.0 : Sat 13 Apr 2024 - 22:00:30 CEST