|
From: | Ilia Mirkin |
Subject: | Re: [Discuss-gnuradio] `s < d_bufsize' failed. |
Date: | Mon, 01 May 2006 18:13:47 -0400 |
User-agent: | Internet Messaging Program (IMP) H3 (4.0.3) |
Quoting Charles Swiger <address@hidden>:
On Mon, 2006-05-01 at 10:38 -0700, Eric Blossom wrote:On Mon, May 01, 2006 at 12:08:57PM -0400, Chuck Swiger wrote: > Any general clues what would be causing: > > python: ./gr_buffer.h:96: unsigned int gr_buffer::index_add(unsigned > int, unsigned int): Assertion `s < d_bufsize' failed. You're probably returning a value from work/general_work that's greater than nouput_items. Add an assert to you code.Look like the old code has a flaw: for (int k = 0; k < noutput_items; k++){ ... out_sample[k] = interp_sample; ... } return k; but modern compilers deallocate the index when the loop is completed (one web page says), so the fix is to use: for (int k = 0; k < noutput_items; k++){ ... out_sample[k] = interp_sample; ... } return noutput_items;
In fact, modern compilers should produce an error on such code since k is used outside of its declared scope, e.g. cat test.c int main() { for (int i = 0; i < 5; i++) { printf("%d\n", i); } printf("%d\n", i); return 0; } gcc -o test ./test.c test.c: In function `main': test.c:2: error: `for' loop initial declaration used outside C99 mode g++ -o test ./test.c test.c: In function `int main()': test.c:7: error: name lookup of `i' changed for new ISO `for' scoping test.c:4: error: using obsolete binding at `i' gcc --version gcc (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2) (the compilers I've tested, 3.3, 3.4, 4.0 all give this error.) Now, you could pass gcc enough flags to make it accept that code (e.g. tell it to not use C99 mode)... but you really shouldn't do that.
[Prev in Thread] | Current Thread | [Next in Thread] |