Array#pack should warn (or raise) if an invalid pack string is given
If garbage characters are inserted into the pack string ruby ignores them:
$ ruby19 -e 'p [1, 2, 3].pack("*N")'
$ ruby19 -e 'p [1, 2, 3].pack("yN")'
Ruby should at least warn like printf when -w is active:
$ ruby19 -we 'printf "%d %d", 1, 2, 3'
-e:1: warning: too many arguments for format string
A future version could raise an exception.
#4 Updated by Eric Hodel almost 2 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35292.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- pack.c (pack_pack): Warn when an invalid character is found in the format string when $VERBOSE is true. [ruby-trunk - Feature #5219]
- pack.c (pack_unpack): ditto
- test/ruby/test_pack.rb (class TestPack): Test for warnings on invalid format characters.