unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmx.net>
To: 10941@debbugs.gnu.org
Subject: bug#10941: [24.0.93.3] cc-mode: error in message buffer when "typing fast", characters eaten
Date: Sun, 4 Mar 2012 21:14:43 +0300	[thread overview]
Message-ID: <201203042114.43740.pogonyshev@gmx.net> (raw)

[-- Attachment #1: Type: Text/Plain, Size: 918 bytes --]

Sometimes (quite often) when opening a different syntax region --- a
quoted string, or block comment --- in C++ mode, the first character
after it gets eaten with some error message shown in the echo area.  I
managed to create a surefire (at least here) way to reproduce it.

* save the attached file as 'test.cpp' (it is quite large, but when I
  tried to shorten it substantially, error disappeared);

* start Emacs as 'emacs -Q test.cpp';

* issue Elisp command right at the start of the buffer with M-: (this
  emulates fast typing):

      (progn (insert "/*") (insert " "))

  note that two separate inserts are essential, with one "/* " error
  is not triggered;

* observer the following error:

      Debugger entered--Lisp error: (error "Invalid search bound
      (wrong side of point)")

Full Emacs version: GNU Emacs 24.0.93.3 (x86_64-unknown-linux-gnu,
GTK+ Version 2.24.10) of 2012-02-25 on gonzo

Paul

[-- Attachment #2: test.cpp --]
[-- Type: text/x-c++src, Size: 3990 bytes --]

namespace mct
{

  // Templated structure specifying how given type could be used by its container (in
  // broad sense), i.e. "externally".  Default is no external use; it can be enabled by
  // specializing the structure.
  template <typename Type, typename = void>
  struct external_use
  { };


  template <typename Type, typename = Type>
  struct supports_external_use : impl::false_type
  { };

  template <typename Type>
  struct supports_external_use <Type, typename external_use <Type>::type> : impl::true_type
  { };


  template <typename Type, typename Value, Value Type::* field,
            bool direct_access = (impl::is_integral <Value>::value
                                  && !impl::is_same <Value, bool>::value),
            bool recurse       = supports_external_use <Value>::value>
  struct extern_use_field;

  template <typename Type, typename Value, Value Type::* field>
  struct extern_use_field <Type, Value, field, true, false>
  {
    typedef  Type   type;
    typedef  Value  value_type;

    static  const value_type&
    get (const type& structure)
    {  return structure.*field;  }

    static  void
    set (type& structure, const value_type& value)
    {  structure.*field = value;  }
  };

  template <typename Type, typename Value, Value Type::* field>
  struct extern_use_field <Type, Value, field, false, true>
  {
    typedef  Type                                       type;
    typedef  typename external_use <Value>::value_type  value_type;

    static  const value_type&
    get (const type& structure)
    {
      return external_use <Value>::get (structure.*field);
    }

    static  void
    set (type& structure, const value_type& value)
    {
      external_use <Value>::set (structure.*field, value);
    }
  };


  template <typename First, typename Second>
  struct external_use <std::pair <First, Second>,
                       typename impl::enable_if <supports_external_use <First>::value>::type>
    : extern_use_field <std::pair <First, Second>, First, &std::pair <First, Second>::first>
  { };

  template <typename First, typename Second>
  struct external_use <std::pair <First, Second>,
                       typename impl::enable_if <supports_external_use <Second>::value
                                                 && !supports_external_use <First>::value>::type>
    : extern_use_field <std::pair <First, Second>, Second, &std::pair <First, Second>::second>
  { };


  namespace impl
  {

    // By default the structure is empty.  'intrusive_storage' below makes sure to never
    // use it when it's empty, i.e. of size 1.
    template <typename type, typename = void>
    struct extern_use_wrapper
    { };


# if 0

    // Ideally we'd want this, but see comment in the preprocessor-enabled branch.
    template <typename type>
    struct extern_use_wrapper <type, typename impl::enable_if <std::is_class <type>::value>::type>
      : type
    // ...

# else

    // We currently specialize 'extern_use_wrapper' very conservatively.  At least GCC up
    // to 4.6 doesn't provide 'std::is_class', so there is no reliable way to determine if
    // 'type' is subclassable without requiring a recent compiler.  The most important
    // case, especially for maps, is 'std::pair', so we limit ourselves to that for now.
    template <typename First, typename Second>
    struct extern_use_wrapper <std::pair <First, Second> > : std::pair <First, Second>
    {
      typedef  std::pair <First, Second>  base_type;

      char  _unused;

      extern_use_wrapper&
      operator= (const extern_use_wrapper& that)
      {
        return static_cast <extern_use_wrapper&> (base_type::operator= (that));
      }

#   if MCT_CXX0X_SUPPORTED

      extern_use_wrapper&
      operator= (extern_use_wrapper&& that)
      {
        return static_cast <extern_use_wrapper&> (base_type::operator=
                                                  (std::forward <base_type> (that)));
      }

#   endif
    };

# endif

  }

}

             reply	other threads:[~2012-03-04 18:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04 18:14 Paul Pogonyshev [this message]
2012-03-29 21:48 ` bug#10941: [24.0.93.3] cc-mode: error in message buffer when "typing fast", characters eaten Alan Mackenzie
2012-03-29 22:11   ` Paul Pogonyshev
2012-03-30 22:19     ` Alan Mackenzie
2012-03-31 20:27       ` Paul Pogonyshev
2012-04-11 18:19   ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201203042114.43740.pogonyshev@gmx.net \
    --to=pogonyshev@gmx.net \
    --cc=10941@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).