This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: How to get more info about 'bad_function_call' ?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Linda A. Walsh" <gcc at tlinx dot org>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 27 Jan 2015 15:42:24 +0000
- Subject: Re: How to get more info about 'bad_function_call' ?
- Authentication-results: sourceware.org; auth=none
- References: <54C7A9F8 dot 70504 at tlinx dot org>
On 27 January 2015 at 15:08, Linda A. Walsh wrote:
> How can I check the validity of what I am about to call and find
> out what is wrong with it before I make the call and am terminated?
By doing exactly that. Check if the std::function you're calling is
valid, e.g. if (f) or if (f == nullptr) or if (!!f) or whatever floats
your boat.
> Is there any debug information I'm missing?
> tracing in gdb at that point shows a check of some
> function against 0 (said it might be an inline function
> as I couldn't print its value), and then the call to bad function.
>
> As a library user and not a library-internals expert -- what
> steps can a user take at this point to figure out what is going on?
Look at the stack trace, find out why the std::function object you're
calling is empty at that point.
Then either fix the code so it isn't empty, or add a check so you
don't call it when it's empty.
Nothing in this question is specific to libstdc++, it's a basic "how
do I use std::function?" question and would be much more appropriate
in a general C++ forum, such as StackOverflow.