Closed
Bug 94685
Opened 25 years ago
Closed 25 years ago
Warnings irk me
Categories
(NSS :: Libraries, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: wtc)
Details
Attachments
(10 files)
|
714 bytes,
text/plain
|
Details | |
|
714 bytes,
text/html
|
Details | |
|
335 bytes,
text/html
|
Details | |
|
373 bytes,
text/html
|
Details | |
|
2.54 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.39 KB,
text/html
|
Details | |
|
411 bytes,
text/html
|
Details | |
|
2.99 KB,
text/html
|
Details | |
|
932 bytes,
text/html
|
Details | |
|
875 bytes,
text/html
|
Details |
Based on the NSS windows tinderbox, i have sorted the issues based on warning
type.
| Reporter | ||
Comment 10•25 years ago
|
||
Comment 11•25 years ago
|
||
r=dbradley
| Assignee | ||
Comment 12•25 years ago
|
||
Timeless, thank you very much for taking the time to
file this bug report on compiler warnings in NSS, complete
with links to the source files.
I did not notice that you attached a patch and had been
wondering what the r=dbradley was for. I just went through
the attachments again and spotted a patch (attach_id=45369)
titled "Fix DLI, MRV, PM". I will review it and check it
in.
Status: NEW → ASSIGNED
| Assignee | ||
Comment 13•25 years ago
|
||
Timeless, I checked in your patch on the trunk of NSS.
I did not check in your change for cmsdigest.c because
the (void *) cast for the argument to PORT_Free is not
necessary.
| Assignee | ||
Comment 14•25 years ago
|
||
OK, I looked closer and found that your (void *) cast
is intended to cast away to 'const'. I will think about
this.
| Assignee | ||
Comment 15•25 years ago
|
||
I think Microsoft Visual C++ 6.0 incorrectly warns about
the following:
------------------
#include <stdlib.h>
int main()
{
const char **p = NULL;
free(p);
return 0;
}
------------------
When I compile it with -W4, the compiler gives the following warnings:
foo.c(6) : warning C4090: 'function' : different 'const' qualifiers
foo.c(6) : warning C4022: 'free' : pointer mismatch for actual parameter 1
But 'p' is not const. 'p' is a non-const pointer pointing at const char.
Brendan, what do you think?
| Assignee | ||
Comment 16•25 years ago
|
||
Correction: my last sentence should read:
But 'p' is not pointing to const data. 'p' is pointing
to a pointer that points at const data.
| Assignee | ||
Comment 17•25 years ago
|
||
Timeless:
I've reviewed all the compiler warnings you found and
fixed the serious ones and the simple ones.
I didn't fix the 'const' warnings whose fix requires
touching a lot of functions (the infamous 'const'
propagation effect). However the simple 'const' warnings
have all been fixed.
I didn't fix the "conversion from () to (), possible loss
of data" and "integral size mismatch in argument; conversion
supplied" warnings because they are either not serious (the
"conversion supplied" ones) or not simple to fix (adding a cast
merely shuts up the compiler without addressing the "possible
loss of data" issue).
If you are satisfied with what I have done, I'll close the
bug. Otherwise, I will leave it open but will assign a low
priority to fixing the rest of the warnings.
Again, thank you for this bug report. It is much easier
than sifting through the build logs.
Comment 18•25 years ago
|
||
I'm sure that warning is useless -- I detest all warnings about pointer const
mismatch when passing a pointer by value to free.
Still, 'different const qualifiers' seems to me a true observation by MSVC of
the type types: free takes void*, you're passing const char**, and the types do
indeed have different const qualifiers. free is going to scribble on the memory
as it goes back to the malloc heap (for debug builds, all over it; otherwise,
perhaps to store backward list linkage in the first word). It's true that you
can store that first word too, via *p = "hello"; or some such. So the const
difference is meaningless as far as free is concerned.
So MSVC is whining about a distinction without a practical difference. That
makes for needless warning noise to precious warning signal, which we ignore at
our peril. File a bug via msdn? And don't hold your breath for a fix.
/be
| Assignee | ||
Comment 19•25 years ago
|
||
If p is declared this way,
const char *p = NULL;
then I agree free(p) should get a warning.
This is because it is illegal to say:
*p = '\0';
But if p is declared like this:
const char **p = NULL;
then p is not pointing to const data and
free(p) should not get a warning. This is
because it is legal to say:
*p = NULL;
| Assignee | ||
Comment 20•25 years ago
|
||
brendan: never mind. I read your comments again and
now I understand what you said.
Comment 21•25 years ago
|
||
wtc: right, we're in agreement -- but I still think that if free could be known
by the compiler as the standard free (the one that goes with malloc), no warning
of any const difference between actual and formal parameter types should be
given -- no such warning is helpful in the real world, it seems to me.
/be
| Reporter | ||
Comment 22•25 years ago
|
||
Well, I'd like to fix some of the things after the current fix, I think ()
unreferenced label, unless you already fixed that. If that's fixed then i think
we can close this.
| Assignee | ||
Comment 23•25 years ago
|
||
Timeless: I should have been more clear. I reviewed not only
your patch but also all the compiler warnings you listed.
I fixed the more serious warnings and the warnings that are
easy to fix, including all the unreferenced labels.
| Reporter | ||
Comment 24•25 years ago
|
||
ok
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•