[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warnings originating in gl2ps -- update
From: |
CdeMills |
Subject: |
Re: warnings originating in gl2ps -- update |
Date: |
Thu, 10 Feb 2011 10:17:06 -0800 (PST) |
John W. Eaton wrote:
>
>
> I'd rather not. First, the C-style cast you are using will result in
> a different warning about that given our GCC warning options, and
> second, I would still like to consider the possibility of having
> different types for indices and dimensions (as does Matlab, with
> mwIndex, mwSignedIndex, and mwSize), so some of the casts that
> you would propose might become unnecessary. And finally, I really
> don't like to see casts, and especially not C-style casts, because
> they will simply hide potential type mismatches that we should know
> about. So before you sprinkle the Octave sources with many more
> casts, explain to me precisely what bad thing could happen in the
> above code. How large would k or dir.length () have to be before you
> would see a problem with octave_idx_type either a 32- or 64-bit signed
> integer? Is that remotely likely to happen? Is it even possible?
>
>
As I showed, despite the warning, the comparison operator generates the
right result. I tested three potentially problematic cases:
dir.length() = UINT_MAX - 5;
1) k = dir.length();
2) k = dir.length() - 10;
3) k = 10;
Another, castless, option, would just be to apply the definition of '<':
as RHS is supposed to be >= LHS, instead of testing
LHS < RHS
we can also test (RHS-LHS) > 0
The corresponding patch is
--- a/src/load-path.cc Thu Feb 10 00:58:31 2011 -0500
+++ b/src/load-path.cc Thu Feb 10 19:15:58 2011 +0100
@@ -617,7 +617,7 @@
while (k > 1 && file_ops::is_dir_sep (dir[k-1]))
k--;
- if (k < dir.length ())
+ if ((dir.length () - k) > 0)
dir.resize (k);
return dir;
This removes the warning.
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/warnings-originating-in-gl2ps-update-tp3298345p3299703.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
- warnings originating in gl2ps -- update, Larry Doolittle, 2011/02/09
- warnings originating in gl2ps -- update, John W. Eaton, 2011/02/10
- warnings originating in gl2ps -- update, John W. Eaton, 2011/02/10
- Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/10
- Re: warnings originating in gl2ps -- update, John W. Eaton, 2011/02/10
- Re: warnings originating in gl2ps -- update,
CdeMills <=
- Re: warnings originating in gl2ps -- update, John W. Eaton, 2011/02/10
- Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/11
- Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/11
- Re: warnings originating in gl2ps -- update, John W. Eaton, 2011/02/11
- Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/13
- Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/10
Re: warnings originating in gl2ps -- update, CdeMills, 2011/02/10