dsw / oink-stack

Oink is a collaboration of C++ static analysis tools.
http://danielwilkerson.com/oink/index.html
154 stars 34 forks source link

Parse error (state 296) at <name>: __niter #10

Open sigmike opened 9 years ago

sigmike commented 9 years ago

Hello,

I get this error in a STL header:

In state 296, I expected one of these tokens:
  (, ), [, ], ->, ., +, -, ++, --, &, *, .*, ->*, /, %, <<, >>, <, <=, >, >=, ==, !=, ^, |, &&, ||, ?, :, =, *=, /=, %=, +=, -=, &=, ^=, |=, <<=, >>=, ,, ..., ;, }, __attribute__, <?, >?, 
/usr/include/c++/4.6/bits/stl_algobase.h:731:32: Parse error (state 296) at <name>: __niter

I've reduced the input with delta to this:

namespace std __attribute__ ((__visibility__ ("default"))) {
  template<class _Sp, class _Tp> struct __traitor {};
  template<typename _Tp> struct __is_integer {};
  template<typename _Tp> struct __is_floating {};
  template<typename _Tp> struct __is_pointer {};
  template<typename _Tp> struct __is_arithmetic : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > {};
  template<typename _Tp> struct __is_scalar : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > {};
}
namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
  template<bool, typename> struct __enable_if {};
}
namespace std __attribute__ ((__visibility__ ("default"))) {
  template<typename _OutputIterator, typename _Size, typename _Tp> inline typename __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value) {
    for (__decltype(__n + 0) __niter = __n; __niter > 0; --__niter, ++__first)
      *__first = __value;
  }

I'm using gcc 4.6.3 and oink master with the lattice config on an clean Ubuntu 12.04. The header comes from the libstdc++6-4.6-dev package.

Edit: Ubuntu 12.04 instead of 14.04

dsw commented 9 years ago

Can I ask you to please make an effort to minimize the input just a bit further? I am rather sure that it can be made a bit smaller; you will likely need to do it by hand rather than using an automated tool such as delta.

Daniel

On Sun, Feb 22, 2015 at 4:59 AM, Michaël Witrant notifications@github.com wrote:

Hello,

I get this error in a STL header:

In state 296, I expected one of these tokens: (, ), [, ], ->, ., +, -, ++, --, &, , ., ->, /, %, <<, >>, <, <=, >, >=, ==, !=, ^, |, &&, ||, ?, :, =, =, /=, %=, +=, -=, &=, ^=, |=, <<=, >>=, ,, ..., ;, }, attribute, <?, >?, /usr/include/c++/4.6/bits/stl_algobase.h:731:32: Parse error (state 296) at : __niter

I've reduced the input with delta to this:

namespace std attribute ((visibility ("default"))) { template<class _Sp, class _Tp> struct traitor {}; template struct is_integer {}; template struct is_floating {}; template struct is_pointer {}; template struct is_arithmetic : public traitor<is_integer<_Tp>, is_floating<_Tp> > {}; template struct __is_scalar : public traitor<is_arithmetic<_Tp>, is_pointer<_Tp> > {}; }namespace __gnu_cxx __attribute ((visibility ("default"))) { template<bool, typename> struct enable_if {}; }namespace std __attribute ((visibility ("default"))) { template<typename _OutputIterator, typename _Size, typename _Tp> inline typename gnu_cxx::__enable_if<!is_scalar<_Tp>::value, _OutputIterator>::type fill_n_a(_OutputIterator first, _Size __n, const _Tp& value) { for (decltype(n + 0) niter = n; niter > 0; --niter, ++first) *first = value; }

I'm using gcc 4.6.3 and oink master with the lattice config on an clean Ubuntu 14.04. The header comes from the libstdc++6-4.6-dev package.

— Reply to this email directly or view it on GitHub https://github.com/dsw/oink-stack/issues/10.

dsw commented 9 years ago

Allow me to clarify: this is a string that the parser cannot parse, so certainly a smaller input will also induce the parser into the same state.

On Mon, Feb 23, 2015 at 12:10 AM, Daniel Wilkerson < daniel.wilkerson@gmail.com> wrote:

Can I ask you to please make an effort to minimize the input just a bit further? I am rather sure that it can be made a bit smaller; you will likely need to do it by hand rather than using an automated tool such as delta.

Daniel

On Sun, Feb 22, 2015 at 4:59 AM, Michaël Witrant <notifications@github.com

wrote:

Hello,

I get this error in a STL header:

In state 296, I expected one of these tokens: (, ), [, ], ->, ., +, -, ++, --, &, , ., ->, /, %, <<, >>, <, <=, >, >=, ==, !=, ^, |, &&, ||, ?, :, =, =, /=, %=, +=, -=, &=, ^=, |=, <<=, >>=, ,, ..., ;, }, attribute, <?, >?, /usr/include/c++/4.6/bits/stl_algobase.h:731:32: Parse error (state 296) at : __niter

I've reduced the input with delta to this:

namespace std attribute ((visibility ("default"))) { template<class _Sp, class _Tp> struct traitor {}; template struct is_integer {}; template struct is_floating {}; template struct is_pointer {}; template struct is_arithmetic : public traitor<is_integer<_Tp>, is_floating<_Tp> > {}; template struct __is_scalar : public traitor<is_arithmetic<_Tp>, is_pointer<_Tp> > {}; }namespace __gnu_cxx __attribute ((visibility ("default"))) { template<bool, typename> struct enable_if {}; }namespace std __attribute ((visibility ("default"))) { template<typename _OutputIterator, typename _Size, typename _Tp> inline typename gnu_cxx::__enable_if<!is_scalar<_Tp>::value, _OutputIterator>::type fill_n_a(_OutputIterator first, _Size __n, const _Tp& value) { for (decltype(n + 0) niter = n; niter > 0; --niter, ++first) *first = value; }

I'm using gcc 4.6.3 and oink master with the lattice config on an clean Ubuntu 14.04. The header comes from the libstdc++6-4.6-dev package.

— Reply to this email directly or view it on GitHub https://github.com/dsw/oink-stack/issues/10.

sigmike commented 9 years ago

Here's a much smaller input:

void a(int b) {
  __decltype(b + 0) c;
}
dsw commented 9 years ago

Thank you for the bug report and the extra effort to minimize the example; however I just have too many other important things to work on right now to spend time on this.

Scott says the following: "There is a debug flag to elkhound that will print all the states and their associated gram[m]ar productions. Use that to decode the state number to see where it got stuck."

If you follow Scott's suggestion, then the output from elkhound about what state the parser is in may tell you how the grammar needs to be altered. Since the grammar is GLR, it is quite robust against shift-reduce and reduce-reduce conflicts, so if you figure out the error, it should be easy to fix.

If you manage to fix it, do send me a pull request and if it looks sane and builds and passes on my machine, I'll incorporate it into the mainline.

Sorry, but I basically have to rely on others to take the time to investigate these bugs right now, but I can offer the kind of advice above and can test and merge fixes when people send them.

Daniel

On Sat, Feb 28, 2015 at 1:26 AM, Michaël Witrant notifications@github.com wrote:

Here's a much smaller input:

void a(int b) { __decltype(b + 0) c; }

— Reply to this email directly or view it on GitHub https://github.com/dsw/oink-stack/issues/10#issuecomment-76518730.