[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55046] Add static compile-time checking of pr
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes |
Date: |
Thu, 29 Nov 2018 12:21:00 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063 |
Follow-up Comment #19, bug #55046 (project octave):
Checking out the errors related to strings, I find this
libinterp/dldfcn/symbfact.cc:380:28: warning: format not a string literal and
no format arguments [-Wformat-security]
And the code for that is
if (! err_msg.empty ())
error (err_msg.c_str ());
This seems like valid syntax to me. I can shut up the error by using
error ("%s", err_msg.c_str ());
but this seems unnecessary.
In error.h the prototype for the error function is
OCTAVE_FORMAT_ATTRIBUTE (__printf__, 1, 2)
OCTAVE_NORETURN OCTINTERP_API extern
void error (const char *fmt, ...);
Do we need a second prototype (and implementation in error.cc) that accepts
just a string and has no OCTAVE_FORMAT_ATTRIBUTE declaration.
For example,
OCTAVE_NORETURN OCTINTERP_API extern
void error (const char *str);
It doesn't really work because the compiler can't distinguish between the two
two prototypes
libinterp/corefcn/error.cc:1957:61: error: call of overloaded ‘error(const
char [40])’ is ambiguous
error ("lasterror: unrecognized string argument");
^
libinterp/corefcn/error.cc:575:1: note: candidate: void error(const char*,
...)
error (const char *fmt, ...)
^~~~~
libinterp/corefcn/error.cc:568:1: note: candidate: void error(const char*)
error (const char *str)
I suppose we could change the prototype
void
error (const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
verror (fmt, args);
va_end (args);
}
to
void
error (const char *fmt, arg1, ...)
{
va_list args;
va_start (arg1, args, fmt);
verror (fmt, args);
va_end (args);
}
Maybe at that point it is better to just introduce the format string "%s".
Thoughts?
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55046>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #55046] Crash with trivial script on dev, (continued)
- [Octave-bug-tracker] [bug #55046] Crash with trivial script on dev, Rik, 2018/11/21
- [Octave-bug-tracker] [bug #55046] Crash with trivial script on dev, Rik, 2018/11/21
- [Octave-bug-tracker] [bug #55046] Crash with trivial script on dev, Rik, 2018/11/21
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Rik, 2018/11/21
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/21
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/23
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/23
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/23
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Rik, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes,
Rik <=
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Markus Mützel, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Rik, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Kai Torben Ohlhus, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Markus Mützel, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Markus Mützel, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Rik, 2018/11/29
- [Octave-bug-tracker] [bug #55046] Add static compile-time checking of printf functions using compiler attributes, Markus Mützel, 2018/11/30