473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

visual c++ .net 2003 bug in c4090 waring

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
--

Dec 29 '05 #1
6 1442
>The C code (not C++) below (test.c) generates a warning:
...
If I compile above with MSVC 7.1:


Murali,

It also does with VC2005 if compiled as 'C' code.

The Comeau online compiler doesn't object, so it may well be an issue
with the MS compiler. I suggest that you submit a bug report on it
against VC2005 (mention that VC2003 is the same too):

http://lab.msdn.microsoft.com/productfeedback/

Post back a link to your bug report and I'll confirm it.

Dave
Dec 30 '05 #2
Hi Dave:

Here is the bug report I created:

http://lab.msdn.microsoft.com/Produc...6-910a36a493ab

A similar one appears to have been reported already (and is marked
not reproducible, not sure why), albeit with regards to memset, but I
think the problem is the same.

http://lab.msdn.microsoft.com/produc...f-95ddb65117e9

Regards,
Murali
--

PS: On an unrelated note, I first tried reporting this as a bug by going to
microsoft.com. I was expecting to find a link where I could put in the
relavant
info and press submit. The best I could do was find this newgroup to post.
Later in the day a collegue pointed me to the lab.* link you mention, I am a
bit
surprised that a link to report bugs (free QE from my point of view) is not
easily found on from the support.microsoft.com web-ste.

-------
"David Lowndes" wrote:
The C code (not C++) below (test.c) generates a warning:
...
If I compile above with MSVC 7.1:


Murali,

It also does with VC2005 if compiled as 'C' code.

The Comeau online compiler doesn't object, so it may well be an issue
with the MS compiler. I suggest that you submit a bug report on it
against VC2005 (mention that VC2003 is the same too):

http://lab.msdn.microsoft.com/productfeedback/

Post back a link to your bug report and I'll confirm it.

Dave

Dec 30 '05 #3
>Here is the bug report I created:

http://lab.msdn.microsoft.com/Produc...6-910a36a493ab
I've validated it and added a comment.
A similar one appears to have been reported already (and is marked
not reproducible, not sure why)...


Sometimes you have to persist with them. It helps when you have the
ability to re-open the bug reports to get them re-checked.

Cheers
Dave
Dec 30 '05 #4
I noticed MS closed it out as by design. I very strongly disagree and it's
sort of a pain for us at our organization because we use -Werr and
simultaneously use different compilers.

You might want to reopen the bug (please). The resopnse from Microsoft
demonstrates a misunderstanding of the const modifier and ANSI C. You are
correct that char ** is compatible with void *.

The warning would be valid if the paramter being passed was const char *
const *.


"Murali Yeddanapudi" wrote:
Hi Dave:

Here is the bug report I created:

http://lab.msdn.microsoft.com/Produc...6-910a36a493ab

A similar one appears to have been reported already (and is marked
not reproducible, not sure why), albeit with regards to memset, but I
think the problem is the same.

http://lab.msdn.microsoft.com/produc...f-95ddb65117e9

Regards,
Murali
--

PS: On an unrelated note, I first tried reporting this as a bug by going to
microsoft.com. I was expecting to find a link where I could put in the
relavant
info and press submit. The best I could do was find this newgroup to post.
Later in the day a collegue pointed me to the lab.* link you mention, I am a
bit
surprised that a link to report bugs (free QE from my point of view) is not
easily found on from the support.microsoft.com web-ste.

-------
"David Lowndes" wrote:
The C code (not C++) below (test.c) generates a warning:
...
If I compile above with MSVC 7.1:


Murali,

It also does with VC2005 if compiled as 'C' code.

The Comeau online compiler doesn't object, so it may well be an issue
with the MS compiler. I suggest that you submit a bug report on it
against VC2005 (mention that VC2003 is the same too):

http://lab.msdn.microsoft.com/productfeedback/

Post back a link to your bug report and I'll confirm it.

Dave

Jan 20 '06 #5
>You might want to reopen the bug (please). The resopnse from Microsoft
demonstrates a misunderstanding of the const modifier and ANSI C. You are
correct that char ** is compatible with void *.


I've re-opened it - let's hope for a better response this time!

Dave
Jan 21 '06 #6
I wish I could quote chapter and verse of ANSI C-99 to which this applies.
If your organization happens to have a copy, try quoting it so you don't have
to defer to the authority of another compiler. Their C++ compiler does
properly handle this by the way.

I mis-typed in the earlier response. I meant to say const char ** is
compatible with void *, not char ** (which of course is also compatible).

In the meantime you can silence the warning with an explicit cast to (void
*), defeating the const violation checking.

"David Lowndes" wrote:
You might want to reopen the bug (please). The resopnse from Microsoft
demonstrates a misunderstanding of the const modifier and ANSI C. You are
correct that char ** is compatible with void *.


I've re-opened it - let's hope for a better response this time!

Dave

Jan 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: angelag | last post by:
I am currently taking a college course in Visual Basic.Net and I am a beginner. I bought Visual Studio.Net 2003 to do my homework at home. I built my first project and e-mailed it to myself at...
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
0
by: Ricardo Dias Marques | last post by:
Hi, I have a development machine with Visual Studio .Net 2003 which, as far as I know, targets the 1.1 .Net Framework. Now I need to open some solutions that were created in another machine...
1
by: xman | last post by:
very hard is fix exactly group for this question.. but I am sure that some of people here have some experience with these compilers: Visual Studio NET Enterprise Architect 2002 and Visual Studio...
1
by: Daniel A. Thomas | last post by:
License required Maybe you don't have this but have one of the products that qualifies for the upgrade such as ... Visual Studio .NET 2003 Professional Visual Studio .NET 2003 Professional...
0
by: summer911 | last post by:
Hi I tried the code below ( xmlParseFile) on my xml file ( see below ) but this gives me a warning message!(OS :redhat9.0) The warning message is :I/O waring :failed to load external extity "" ...
26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
10
by: Jonathan Wilson | last post by:
Firstly, to get msvcrt.lib, install the .NET framework SDK. The version of msvcrt.lib included there is the exact same one as comes with Visual Studio ..NET 2003. There are some other things that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.