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 o autor
Navegue por canal
Automação
Últimas novidades em automação de TI para empresas de tecnologia, equipes e ambientes
Inteligência artificial
Descubra as atualizações nas plataformas que proporcionam aos clientes executar suas cargas de trabalho de IA em qualquer ambiente
Nuvem híbrida aberta
Veja como construímos um futuro mais flexível com a nuvem híbrida
Segurança
Veja as últimas novidades sobre como reduzimos riscos em ambientes e tecnologias
Edge computing
Saiba quais são as atualizações nas plataformas que simplificam as operações na borda
Infraestrutura
Saiba o que há de mais recente na plataforma Linux empresarial líder mundial
Aplicações
Conheça nossas soluções desenvolvidas para ajudar você a superar os desafios mais complexos de aplicações
Programas originais
Veja as histórias divertidas de criadores e líderes em tecnologia empresarial
Produtos
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Red Hat Cloud Services
- Veja todos os produtos
Ferramentas
- Treinamento e certificação
- Minha conta
- Suporte ao cliente
- Recursos para desenvolvedores
- Encontre um parceiro
- Red Hat Ecosystem Catalog
- Calculadora de valor Red Hat
- Documentação
Experimente, compre, venda
Comunicação
- Contate o setor de vendas
- Fale com o Atendimento ao Cliente
- Contate o setor de treinamento
- Redes sociais
Sobre a Red Hat
A Red Hat é a líder mundial em soluções empresariais open source como Linux, nuvem, containers e Kubernetes. Fornecemos soluções robustas que facilitam o trabalho em diversas plataformas e ambientes, do datacenter principal até a borda da rede.
Selecione um idioma
Red Hat legal and privacy links
- Sobre a Red Hat
- Oportunidades de emprego
- Eventos
- Escritórios
- Fale com a Red Hat
- Blog da Red Hat
- Diversidade, equidade e inclusão
- Cool Stuff Store
- Red Hat Summit