Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
b88d2612
Commit
b88d2612
authored
Jun 06, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an issue with allocation of a zero-size array.
parent
d9f5089a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
format.h
format.h
+13
-1
No files found.
format.h
View file @
b88d2612
...
...
@@ -539,6 +539,17 @@ template <typename Char>
int
ParseNonnegativeInt
(
const
Char
*&
s
,
const
char
*&
error
)
FMT_NOEXCEPT
(
true
);
// Computes max(Arg, 1) at compile time. It is used to avoid errors about
// allocating an array of 0 size.
template
<
unsigned
Arg
>
struct
NonZero
{
enum
{
VALUE
=
Arg
};
};
template
<
>
struct
NonZero
<
0
>
{
enum
{
VALUE
=
1
};
};
}
// namespace internal
/**
...
...
@@ -926,6 +937,7 @@ class BasicWriter {
public:
using
ArgInfo
::
type
;
BasicArg
()
{}
BasicArg
(
short
value
)
{
type
=
INT
;
this
->
int_value
=
value
;
}
BasicArg
(
unsigned
short
value
)
{
type
=
UINT
;
this
->
int_value
=
value
;
}
BasicArg
(
int
value
)
{
type
=
INT
;
this
->
int_value
=
value
;
}
...
...
@@ -1151,7 +1163,7 @@ class BasicWriter {
template
<
typename
...
Args
>
void
printf
(
BasicStringRef
<
Char
>
format
,
const
Args
&
...
args
)
{
Arg
arg_array
[]
=
{
args
...};
Arg
arg_array
[
internal
::
NonZero
<
sizeof
...(
Args
)
>::
VALUE
]
=
{
args
...};
vprintf
(
format
,
sizeof
...(
Args
),
arg_array
);
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment