bugGNU Octave - Bugs: bug #62851, num2str: warning: concatenation of...


bug #62851: num2str: warning: concatenation of different character string types may have unintended consequences

Submitter:  None
Submitted:  Mon 01 Aug 2022 08:44:37 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:  Bill Packard Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Tue 30 Aug 2022 12:18:42 PM UTC, comment #5: 

This is "just" a warning that only occurs if a user changes the default warning state. This doesn't need to be fixed for a minor release. Changing target release to "dev".

Markus Mützel <mmuetzel>
Project Member
Tue 02 Aug 2022 12:26:46 PM UTC, comment #4: 

I don't know what the guideline is for warnings that are disabled by default.

CC'ing jwe: Should functions in core Octave still run without warnings if a user enables warnings that are disabled by default?

Markus Mützel <mmuetzel>
Project Member
Tue 02 Aug 2022 12:09:42 PM UTC, comment #3: 

checked warnings:

>> warning

By default, warnings are disabled.


Also checked all script files and found a command to first turn off all warnings, then a subsequent one to turn on all warnings. Removing these eliminates the warning.

With the warning on, I was unable to change the string components to alleviate the warning, so I wonder if something should be changed? It didn't matter whether I was using only single quoted strings or double quoted. When I changed the quoting in line 143 of num2str, it did silence the warning.

Tue 02 Aug 2022 07:17:00 AM UTC, comment #2: 

I'm unable to reproduce this here with Octave 7.2.0.

You might have activated that warning (e.g., by calling "warning on" somewhere).
What does `warning` return for you? For me, it does the following:

>> warning
By default, warnings are enabled.
Non-default warning states are:

  State  Warning ID
    off  Octave:array-as-logical
    off  Octave:array-to-scalar
    off  Octave:array-to-vector
    off  Octave:imag-to-real
    off  Octave:language-extension
    off  Octave:missing-semicolon
    off  Octave:neg-dim-as-zero
    off  Octave:separator-insert
    off  Octave:single-quote-string
    off  Octave:str-to-num
    off  Octave:mixed-string-concat
    off  Octave:variable-switch-label

Markus Mützel <mmuetzel>
Project Member
Tue 02 Aug 2022 01:48:05 AM UTC, comment #1: 

Running str2num(fliplr(num2str((1:100)'))) does not preserve length by adding zeroes.

Mon 01 Aug 2022 08:44:37 PM UTC, original submission:  

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

Windows 10
Octave 7.1.0
(side note, unable to disable any or all warnings)

this error seems to show up for any use of num2str with a double quoted string.

changing line 143 in num2str.m as indicated seems to eliminate the warning:

%%      fmt = [deblank(repmat (fmt, 1, nc)), "\n"];
      fmt = [deblank(repmat (fmt, 1, nc)), '\n'];

>>>disp(['num2str warning: ', num2str("34"), '.']);

will display the warning



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

Attach Files:

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 mmuetzel
  • -email is unavailable- added by mmuetzel (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 project members can vote.





    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-30 mmuetzel Release7.1.0 dev
    2022-08-02 mmuetzel Operating SystemMicrosoft Windows Any
        Carbon-Copy- Added jwe
    2022-08-02 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.9