Stream: brlcad

Topic: C++ 11-ism


view this post on Zulip starseeker (May 19 2018 at 02:26):

Hmm - clang 6 caught a C++11 bit in reduce_db.cpp, looks like:

src/librt/reduce_db.cpp:55:43: error: non-type template argument referring to function 'autoptr_wrap_bu_free<directory *>' with internal linkage is a C++11 extension [-Werror,-Wc++11-extensions]
template <typename T, void free_fn(T *) = autoptr_wrap_bu_free>
^~~~~~~~~~~~~~~~~~~~

view this post on Zulip starseeker (May 19 2018 at 02:27):

@Sean What do we want to do about that one?

view this post on Zulip starseeker (May 19 2018 at 02:29):

Ugh, there's a few more of them

view this post on Zulip Sean (May 19 2018 at 03:50):

@Sean What do we want to do about that one?

have to read up on that as that's new syntax to me, but at a glance, just looks like an expansion for what was previously just a typename.
would become something like: template <typename T, typename free_fn = autoptr_wrap_bu_free>

view this post on Zulip Sean (May 19 2018 at 03:50):

I'm rusty on my template syntax, so almost certainly butchered that

view this post on Zulip Sean (May 19 2018 at 04:24):

Ugh, there's a few more of them

@starseeker I'm a bit concerned by the callback function commit solution ... casting them away is just a really verbose way of disabling the warning. I thought it might have just been a compiler being picky, but then I looked up the standard and they are undefined behavior. We're in the wrong. Better would be to fix them, especially now that there's a good way to detect them.

view this post on Zulip Sean (May 19 2018 at 04:57):

yeah, the double cast essentially makes them undetectable again

view this post on Zulip starseeker (May 19 2018 at 15:00):

I'm not in my wheelhouse here, but what I'm seeing online suggests it might be more complicated - something about external vs internal linkage and what's allowed to be external before C++11

view this post on Zulip starseeker (May 19 2018 at 15:22):

@Sean If you can help me figure out the new pattern I'll propagate it through the other places where we've got something similar, but I'm not sure what the "right" C++98 thing to do here is.


Last updated: Oct 09 2024 at 00:44 UTC