Issue #5219 has been reported by Eric Hodel.

----------------------------------------
Bug #5219: Array#pack should warn (or raise) if an invalid pack string is given
http://redmine.ruby-lang.org/issues/5219

Author: Eric Hodel
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2011-08-21 revision 33020) [x86_64-darwin11.1.0]


If garbage characters are inserted into the pack string ruby ignores them:

$ ruby19 -e 'p [1, 2, 3].pack("*N")'
"\x00\x00\x00\x01"

$ ruby19 -e 'p [1, 2, 3].pack("yN")'
"\x00\x00\x00\x01"

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.

See also: https://github.com/rubinius/rubinius/issues/1127


-- 
http://redmine.ruby-lang.org