Dekel Tsur <[EMAIL PROTECTED]> writes:
| On Mon, May 28, 2001 at 07:36:34AM +0200, Andre Poenitz wrote:
| > > See bug.lyx
| >
| > This one loads without problems... Strange thing.
|
| I get a crash because I use lyxstring and not std::string.
| The problem is in the line 'mm->valign(valign[0]);' in math_parser.C
| (line 804):
| If valign is empty, then valign[0] fails the assertion
| 'lyx::Assert(pos < rep->sz);' in lyxstring::operator[] as pos = rep->sz = 0.
|
| PS: Why lyxstring::const_reference lyxstring::operator[](size_type) const
| and lyxstring::reference lyxstring::operator[](size_type pos) have different
| assertions ? Namely,
| lyx::Assert(pos <= rep->sz);
| vs
| lyx::Assert(pos < rep->sz);
That would be a bug then... what does the standard say...?
ok, the standard say nothing about operator [] but for at it is "<",
but! you also see special code in
lyxstring::const_reference lyxstring::operator[](size_type pos) const
{
lyx::Assert(pos <= rep->sz); // OURS!
static char helper = '\0';
return pos == rep->sz ? helper : rep->s[pos];
}
to handle the pos == rep->sz case... and to me this seems a bit
bogus.. I wonder why it was added...
I think this would work just as well:
lyxstring::const_reference lyxstring::operator[](size_type pos) const
{
lyx::Assert(pos < rep->sz); // OURS!
return rep->s[pos];
}
Please test this.
--
Lgb