Clang 15 will be available with Red Hat Enterprise Linux (RHEL) 8.8 and RHEL 9.2. It comes with some new and upgraded warnings that will help modernize your C/C++ code base. Starting with version 15, Clang is beginning to emit more warnings and errors by default for code constructs that have been deprecated in newer versions of C. This includes implicit function definitions and functions without prototypes.
-Wint-conversion
In Clang 15, the -Wint-conversion warning has been upgraded to an error. This warning catches when an integer is being implicitly converted to a pointer. One common mistake that this warning will catch is implicit function definitions, where code tries to call a function that has not been declared. In C89/C90, undeclared functions are assumed to return int, so if you try to assign the value of an undeclared function to a pointer, Clang will now emit this error:
$ cat int-conversion.c int foo () { char *s = missing_decl(); } $ clang -c int-conversion.c int-conversion.c:2:13: warning: call to undeclared function 'missing_decl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] char *s = missing_decl(); ^ int-conversion.c:2:9: error: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion] char *s = missing_decl(); ^ ~~~~~~~~~~~~~~ 1 warning and 1 error generated.
-Wdeprecated-non-prototype
-Wdeprecated-non-prototype is a new warning that will catch cases where a deprecated prototype would have a different behavior in C2x.
cat deprecated-non-prototype.c static void f(); static void f(char *s) { } [root@intel-xeon-ee-iotg-04 ~]# clang -c deprecated-non-prototype.c deprecated-non-prototype.c:1:13: warning: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C2x, conflicting with a subsequent definition [-Wdeprecated-non-prototype] static void f(); ^ deprecated-non-prototype.c:3:13: note: conflicting prototype is here static void f(char *s) { } ^ 1 warning generated.
Definition without a prototype
Clang 15 will now emit an error if you forget the prototype in a function definition that has a declaration with a prototype.
cat prototype.c void f(int); void f() {} clang -c prototype.c prototype.c:1:19: error: conflicting types for 'f' void f(int); void f() {} ^ prototype.c:1:6: note: previous declaration is here void f(int); void f() {} ^ 1 error generated.
-Wunused-but-set-variable improvements
The -Wunused-but-set-variable warning, which checks for unused variables in the code, has been updated to be able to detect variables for unary operators like ++.
$ cat unused-but-set.c void do_something(void); void f(void) { int count, i; count = 0; for (i = 0; i < 5; i++) { do_something(); count++; } } $ clang -c unused-but-set.c -Wunused-but-set-variable unused-but-set.c:5:6: warning: variable 'count' set but not used [-Wunused-but-set-variable] int count, i; ^ 1 warning generated.
Learn more
While Clang 15 won’t be available in RHEL until the forthcoming minor releases are out, you can get a preview of the latest Clang 15 builds from CentOS Stream. Even if you are using Gnu Compiler Collection (GCC), or an older version of Clang as the compiler for your application, you can still do a one-off build with Clang 15 to see these new warnings and errors to catch any existing mistakes in your code. Clang 16 and future versions of GCC will become even more strict about deprecated C constructs, so it’s a good idea to start finding these problems as soon as you can.
Sobre el autor
Navegar por canal
Automatización
Las últimas novedades en la automatización de la TI para los equipos, la tecnología y los entornos
Inteligencia artificial
Descubra las actualizaciones en las plataformas que permiten a los clientes ejecutar cargas de trabajo de inteligecia artificial en cualquier lugar
Nube híbrida abierta
Vea como construimos un futuro flexible con la nube híbrida
Seguridad
Vea las últimas novedades sobre cómo reducimos los riesgos en entornos y tecnologías
Edge computing
Conozca las actualizaciones en las plataformas que simplifican las operaciones en el edge
Infraestructura
Vea las últimas novedades sobre la plataforma Linux empresarial líder en el mundo
Aplicaciones
Conozca nuestras soluciones para abordar los desafíos más complejos de las aplicaciones
Programas originales
Vea historias divertidas de creadores y líderes en tecnología empresarial
Productos
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Servicios de nube
- Ver todos los productos
Herramientas
- Training y Certificación
- Mi cuenta
- Soporte al cliente
- Recursos para desarrolladores
- Busque un partner
- Red Hat Ecosystem Catalog
- Calculador de valor Red Hat
- Documentación
Realice pruebas, compras y ventas
Comunicarse
- Comuníquese con la oficina de ventas
- Comuníquese con el servicio al cliente
- Comuníquese con Red Hat Training
- Redes sociales
Acerca de Red Hat
Somos el proveedor líder a nivel mundial de soluciones empresariales de código abierto, incluyendo Linux, cloud, contenedores y Kubernetes. Ofrecemos soluciones reforzadas, las cuales permiten que las empresas trabajen en distintas plataformas y entornos con facilidad, desde el centro de datos principal hasta el extremo de la red.
Seleccionar idioma
Red Hat legal and privacy links
- Acerca de Red Hat
- Oportunidades de empleo
- Eventos
- Sedes
- Póngase en contacto con Red Hat
- Blog de Red Hat
- Diversidad, igualdad e inclusión
- Cool Stuff Store
- Red Hat Summit