Note that there are some explanatory texts on larger screens.

plurals
  1. POmemset used with zero length parameter: ignore or watch out?
    primarykey
    data
    text
    <p>I'm having trouble finding any information regarding the following warning when linking a dynamic library:</p> <pre><code>In function `MyClass::myfunc()': MyClass.cpp:(.text+0x14e4): warning: memset used with constant zero length parameter; this could be due to transposed parameters </code></pre> <p>Here is an excerpt of <code>myfunc</code>:</p> <pre><code>void MyClass::myfunc() { vector&lt;Variable*&gt;::const_iterator it; for (it = m_vars.begin(); it != m_vars.end(); ++it) { if ((*it)-&gt;recordme) { MyRecord* r = new MyRecord(*it); initMyRecord(*r); m_records.push_back(r); } } } </code></pre> <p>So I'm pretty much stuck on were should I be looking for possible causes for this memset. The call to the new operator is my first suspect, but I'm not even sure if it's worth looking for this. I'm not sure either if I should take this warning seriously or let it pass.</p> <p>Question: what should I do about this warning? And what kind of patterns should I look out for in order to assure that I'm not going to shoot myself in the foot later?</p> <p>Update: Here is the MyRecord constructor, which is in a header file, so it might or might not be inlined, if I understand correctly.</p> <pre><code>class MyRecord { public: MyRecord(const Variable* var) : buffer(0), lastSave(-1 * std::numeric_limits&lt;double&gt;::max()), sample(100), bufsize(100), gv(var), rec_function(0) {}; virtual ~Record() { if (rec_function) delete rec_function; rec_function = 0; }; private: Record(const Record&amp;); Record&amp; operator=(const Record&amp; rec); public: // @todo: remove publicness boost::circular_buffer&lt; boost::tuple&lt;double,boost::any&gt; &gt; buffer; double lastSave; double sample; unsigned int bufsize; const Variable* gv; RecordFunctor* rec_function; }; </code></pre> <p>The RecordFunctor is a pure-virtual struct:</p> <pre><code>struct RecordFunctor { virtual ~RecordFunctor() {}; virtual void record(const double) = 0; }; </code></pre> <p>Additional info? I'm compiling with flags <code>-O2</code> and g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload