bugGNU Octave - Bugs: bug #66647, num2str gives an unexpected...

 
 

bug #66647: num2str gives an unexpected warning about concatenation

Submitter:  None
Submitted:  Thu 09 Jan 2025 02:07:01 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Need Info Assigned to:  None
Originator Name:  Roger Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 8.4.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 10 Jan 2025 09:14:15 AM UTC, comment #5: 

Hi Dmitri and Rik. Thank you for your responses. It seems to me that an upgrade to the current stable branch wouldn't have solved this particular issue, but next time, I'll check on different versions before filing a bug report. Thank you for the pointer.

Indeed, 'Octave:mixed-string-concat' got inadvertantly set to 'on' in a script that I had run previously. There was a

warning on

statement in a part that I wrote 15 years ago, which I hadn't noticed.

warning ('off', 'Octave:mixed-string-concat')

prevents the warning from coming up. I'm glad to know the root cause now: functions not returning the same type, as you explained in the Discourse topic.

I can now no longer reproduce the warning after plot(1:10). I ran the same code that I was working on previously an that didn't make the warning come up again.

Anonymous
Thu 09 Jan 2025 09:42:17 PM UTC, comment #4: 

I opened up a Discourse topic for maintainers about the underlying issue.  See https://octave.discourse.group/t/purpose-and-future-of-warning-octave-mixed-string-concat/6108.

Rik <rik5>
Group administrator
Thu 09 Jan 2025 09:33:12 PM UTC, comment #3: 

If I enable this warning, I can reproduce "num2str(2)"
but not the "plot(1:10)" messages (octave 10).


octave:6> warning ('on', 'Octave:mixed-string-concat')
octave:7> warning ('query', 'Octave:mixed-string-concat')
"Octave:mixed-string-concat" warning state is "on"
octave:8> num2str(2)
warning: concatenation of different character string types may have unintended consequences
warning: called from
    num2str at line 143 column 7

ans = 2
octave:9> plot(1:10)
octave:10>


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 09 Jan 2025 09:11:01 PM UTC, comment #2: 

As noted in comment #1, version 8.4.0 is quite old and no longer supported.  Please try upgrading to current stable branch (9.X).  We can hold the bug open for a few days until you have verified.

There is also a small possibility that you have enabled a warning that is typically turned off.  Could you run Octave and try this code:


warning ('query', 'Octave:mixed-string-concat')


It should be "off".  If this returns "on" then disable it with


warning ('off', 'Octave:mixed-string-concat')



Rik <rik5>
Group administrator
Thu 09 Jan 2025 05:44:37 PM UTC, comment #1: 

You should report it to Ubuntu.
8.4.0 is an old version.

On ubuntu 24.10: I cannot reproduce the problem with neither
octave 9.2 (provided by distro) nor with self-compiled octave 10.
I am also pretty certain we would have caught an issue with
"plot (1:10)" back in the day when 8.4 was current.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 09 Jan 2025 02:07:01 PM UTC, original submission:  

The command:

num2str(2)

gives the warning:

warning: concatenation of different character string types may have unintended consequences
warning: called from
    num2str at line 143 column 11

ans = 2

I don't expect this warning, as there does not seem to be any concatenation taking place. The output, a character string "2" is correct though.

I tried different inputs. Curiously, mat2str([2]) does not give a warning, just the string "2".

While diagnosing the issue, I noticed that

plot(1:10)

also gives an unexpected warning, which also involves unexpected string conversion:

warning: implicit conversion from string to real matrix
warning: called from
    __pltopt__>decode_linespec at line 161 column 9
    __pltopt__ at line 116 column 27
    __next_line_style__ at line 58 column 11
    __plt__>__plt2vv__ at line 495 column 25
    __plt__>__plt2__ at line 248 column 14
    __plt__>__plt1__ at line 207 column 10
    __plt__ at line 121 column 16
    plot at line 235 column 10


I installed octave from the repository (8.4.0-1build5, Ubuntu 24.04.1 LTS).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-01-09 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.14-708e.
    Corresponding source code