Clang warning: cannot delete expression with pointer-to-'void' type A [-Wdelete-incomplete] (ext_delete_void_ptr_operand)
Jump to navigation
Jump to search
Text | error: cannot delete expression with pointer-to-'void' type A |
---|---|
Type | Warning |
Category | Semantic Issue |
Internal Id | ext_delete_void_ptr_operand |
Active by Default | Yes |
Flags | -Wno-delete-incomplete (2 elements) |
Internal Message | cannot delete expression with pointer-to-'void' type %0
|
Regular Expression | (?:warning|error|fatal error)\: cannot delete expression with pointer\-to\-'void' type (.*?) \[(?:\-Werror,)?\-Wdelete\-incomplete[^\]]*\]
|
First Commit | 2010-05-24 bb3348ed33ac Downgrade deletion of a void* from an error (which is should be) to an |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
#include <stdlib.h>
int main() {
void *p = malloc(10); // allocated as void*
delete p; // issue: can't delete void* with delete
return 0;
}
| |
Compiler Output |
<source>:5:5: warning: cannot delete expression with pointer-to-'void' type 'void *' [-Wdelete-incomplete] |
Clang Internals (17.0.6)
Git Commit Message
Downgrade deletion of a void* from an error (which is should be) to an extension warning (which other compilers seem to use). Works around a known bug in Xalan. llvm-svn: 104509
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaExprCXX.cpp (line 3685)
/// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
/// @code ::delete ptr; @endcode
/// or
/// @code delete [] ptr; @endcode
ExprResult Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *ExE) {
// ...
if (!Ex.get()->isTypeDependent()) {
// ...
if (Pointee->isVoidType() && !isSFINAEContext()) {
// ...
Diag(StartLoc, diag::ext_delete_void_ptr_operand) << Type << Ex.get()->getSourceRange();
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/new-delete.cpp
- clang/test/SemaCXX/new-delete.cpp:174:3: warning: cannot delete expression with pointer-to-'void' type 'void *' [-Wdelete-incomplete]