G
Guest
Hi
The C code (not C++) below (test.c) generates a warning:
#include <stdlib.h>
int main()
{
const char** a = (const char**) malloc(1*sizeof(const char*));
a[0] = "boo";
free(a);
return(0);
}
If I compile above with MSVC 7.1:
I:\tmp>cl test.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
test.c
test.c(6) : warning C4090: 'function' : different 'const' qualifiers
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
I believe this is not correct as I am not freeing the const data that is
being pointed to, only the non-const array of pointers.
Is this a compiler bug or am I missing sometihng?
Thanks,
Murali
--
The C code (not C++) below (test.c) generates a warning:
#include <stdlib.h>
int main()
{
const char** a = (const char**) malloc(1*sizeof(const char*));
a[0] = "boo";
free(a);
return(0);
}
If I compile above with MSVC 7.1:
I:\tmp>cl test.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
test.c
test.c(6) : warning C4090: 'function' : different 'const' qualifiers
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
I believe this is not correct as I am not freeing the const data that is
being pointed to, only the non-const array of pointers.
Is this a compiler bug or am I missing sometihng?
Thanks,
Murali
--