Opened 14 years ago

Closed 14 years ago

Last modified 10 years ago

#2774 closed Bugs (invalid)

boost::tokenize fails on Ubuntu8.10 64bit

Reported by: grumbel@… Owned by: jsiek
Milestone: Component: tokenizer
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

The code in the attached file fails to report the proper tokens on Ubuntu8.10 64bit, while it works fine in the 32bit edition:

The output on 64bit is:

$ ./token hallo:du:da Token: 'hallo' Token: 'o' Token: 'da'

On 32bit it is as expected:

$ ./token hallo:du:da Token: 'hallo' Token: 'du' Token: 'da'

Attachments (1)

token.cpp (567 bytes ) - added by grumbel@… 14 years ago.
Tokenizer Example

Download all attachments as: .zip

Change History (3)

by grumbel@…, 14 years ago

Attachment: token.cpp added

Tokenizer Example

comment:1 by Steven Watanabe, 14 years ago

Resolution: invalid
Status: newclosed

tokenizer does not store a copy of the string, it stores a pair of iterators. The temporary string that you are passing to the constructor is immediately destroyed, invalidating the iterators.

This works:

      std::string arg(argv[1]);
      tokenizer tokens(arg, sep);

comment:2 by william.l.blevins@…, 10 years ago

How is this ticket invalid?

BoostTokenizer provides a constructor that allows for:

  1. memory corruption
  2. tokens are arbitrarily parsed incorrectly
// This should be valid
tokenizer tokens(std::string(argv[1]), sep);

There should at least be documentation for a precondition {@precondition} where this case is listed explicitly.

Note: See TracTickets for help on using tickets.