In this code block, theme_status_messages() hardcodes a 0 index for the $messages array when theming a single value message array:
<?php
if (count($messages) > 1) {
$output .= "<ul>\n";
foreach ($messages as $message) {
$output .= ' <li>'. $message . "</li>\n";
}
$output .= "</ul>\n";
}
else {
$output .= $messages[0];
}
?>
The problem is that if you're doing any sort of manual interaction with the messages session variable, you may end up with a single value array that does not have a 0 key. Instead of adding $messages[0] to $output, this could be changed to reset($messages) if desired. I'm sure there are other ways to deal with this, the most robust of which will not get into 7.x - provide a proper API around status messages. ^_^