[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warnings shut off in ov.cc?
From: |
Rik |
Subject: |
Re: warnings shut off in ov.cc? |
Date: |
Wed, 16 Oct 2019 14:03:42 -0700 |
On 10/16/2019 12:47 PM, John W. Eaton wrote:
> On 10/15/19 9:15 PM, Rik wrote:
>
>> It is possible to detect that a warning has been issued and avoid constant
>> folding, although the mechanism is clumsy. This diff does it
>
> Thanks for the patch. I made a similar change but used an unwind_protect
> object and did the same for array objects. I checked it in here:
>
> http://hg.savannah.gnu.org/hgweb/octave/rev/c3e24c82157f
I thought there must be an easier way. With your change in place I easily
completed the rest of the changeset which adds two new warning IDs when the
colon operator is called in questionable ways. The first ID is
Octave:colon-complex-arg and is triggered by an expression such as 1:5i.
The second ID is Octave:colon-nonscalar-arg and is triggered by an
expression such as 1:[3,5]. This ID is disabled when --traditional mode is
used since Matlab doesn't validate their inputs as tightly as Octave. See
https://hg.savannah.gnu.org/hgweb/octave/rev/85ad4689aa05.
Final note, I had written such a complex warning detection scheme to handle
this oddball case I found where the interpreter produces different results
for the same input (because of global state held in the lastwarn() variable).
octave:1> 1:warning('xyz'):5
warning: xyz
ans = [](1x0)
octave:2> 1:warning('xyz'):5
warning: xyz
warning: colon arguments should be scalars
ans = 1
octave:3> lastwarn ("")
octave:4> 1:warning('xyz'):5
warning: xyz
ans = [](1x0)
Up to you whether this is really worth fixing. I wouldn't bother.
--Rik