ctaggart / octh

Rust bindings for GNU Octave oct.h
14 stars 4 forks source link

error[E0428]: the name `sentry` is defined multiple times #29

Closed ctaggart closed 7 years ago

ctaggart commented 7 years ago
error[E0428]: the name `sentry` is defined multiple times
    --> src/lib.rs:2320:9
     |
2284 |         pub struct sentry {}
     |         -------------------- previous definition of the type `sentry` here
...
2320 |         pub struct sentry {}
     |         ^^^^^^^^^^^^^^^^^^^^ `sentry` redefined here
     |
     = note: `sentry` must be defined only once in the type namespace of this module
ctaggart commented 7 years ago

https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.0/ostream-source.html

00056 template<typename _CharT, typename _Traits> 00057 class basic_ostream : virtual public basic_ios<_CharT, _Traits>

00116 class sentry; 00117 friend class sentry;

ctaggart commented 7 years ago

After a few hours, it didn't find what I wanted. I must have something wrong in the script.

(93.2 %, 276922 bytes)
(100.0 %, 0 bytes)

The file being reduced has reached zero size; our work here is done.

If you did not want a zero size file, you must help C-Reduce out by
making sure that your interestingness test does not find files like
this to be interesting.

real    290m57,710s
user    489m35,680s
sys     100m6,760s
#!/usr/bin/env bash
set -eu
clang-3.9 --std=c++11 -c __bindgen.ii

~/rust-bindgen/target/release/bindgen \
    --output __bindgen.rs \
    --enable-cxx-namespaces \
    --whitelist-type octave.* \
    --whitelist-function octave.* \
    --use-core \
    __bindgen.ii \
    -- -v -x c++ -std=c++11 \
    2>/dev/null

rustc ~/octh/bindgen.rs \
    2>&1 \
    | grep 'error\[E0428\]: the name `sentry` is defined multiple times'

# time creduce ./bindgen-bug.sh __bindgen.ii
ctaggart commented 7 years ago

Oh, I see my script problem. I had created an ~/octh/bindgen.rs with this, hoping it would pick up a file local to the temporary creduce directory. Guess this doesn't work:

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

extern crate core;

include!("__bindgen.rs");

Deleting that file, and switching back to:

#!/usr/bin/env bash
set -eu
clang-3.9 --std=c++11 -c __bindgen.ii

~/rust-bindgen/target/release/bindgen \
    --output __bindgen.rs \
    --enable-cxx-namespaces \
    --whitelist-type octave.* \
    --whitelist-function octave.* \
    --use-core \
    --raw-line "extern crate core;" \
    __bindgen.ii \
    -- -v -x c++ -std=c++11 \
    2>/dev/null

rustc __bindgen.rs \
    2>&1 \
    | grep 'error\[E0428\]: the name `sentry` is defined multiple times'

# time creduce ./bindgen-bug.sh __bindgen.ii
ctaggart commented 7 years ago
namespace a {
template <typename, typename> class b;
template <typename, typename = int> class c;
class B {
  typedef b<int, int> d;
};
class e {
  B g;
};
template <typename, typename> class c : e { class sentry; };
template <typename f, typename h> class c<f, h>::sentry {};
template <typename, typename> class b { class sentry; };
template <typename f, typename h> class b<f, h>::sentry {};
}
class octave_diary_stream : a::c<char> {};
real    310m8,693s
user    509m37,296s
sys     149m29,884s
ctaggart commented 7 years ago

Fixed in bindgen. Just do a cargo update.