Skip to content

Commit 9ea3f45

Browse files
author
Steve Hanson
committed
fix the warning
1 parent 864e44a commit 9ea3f45

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

include/rapidjson/uri.h

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,27 @@ class GenericUri {
238238

239239
// Allocate one block containing each part of the URI (5) plus base plus full URI, all null terminated.
240240
// Order: scheme, auth, path, query, frag, base, uri
241+
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
241242
size_t total = (3 * len + 7) * sizeof(Ch);
242243
scheme_ = static_cast<Ch*>(allocator_->Malloc(total));
243244
*scheme_ = '\0';
244-
auth_ = scheme_ + 1;
245+
auth_ = scheme_;
246+
auth_++;
245247
*auth_ = '\0';
246-
path_ = auth_ + 1;
248+
path_ = auth_;
249+
path_++;
247250
*path_ = '\0';
248-
query_ = path_ + 1;
251+
query_ = path_;
252+
query_++;
249253
*query_ = '\0';
250-
frag_ = query_ + 1;
254+
frag_ = query_;
255+
frag_++;
251256
*frag_ = '\0';
252-
base_ = frag_ + 1;
257+
base_ = frag_;
258+
base_++;
253259
*base_ = '\0';
254-
uri_ = base_ + 1;
260+
uri_ = base_;
261+
uri_++;
255262
*uri_ = '\0';
256263
return total;
257264
}
@@ -293,7 +300,9 @@ class GenericUri {
293300
}
294301
}
295302
// Look for auth (//([^/?#]*))?
296-
auth_ = scheme_ + GetSchemeStringLength() + 1;
303+
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
304+
auth_ = scheme_ + GetSchemeStringLength();
305+
auth_++;
297306
*auth_ = '\0';
298307
if (start < len - 1 && uri[start] == '/' && uri[start + 1] == '/') {
299308
pos2 = start + 2;
@@ -308,7 +317,9 @@ class GenericUri {
308317
start = pos2;
309318
}
310319
// Look for path ([^?#]*)
311-
path_ = auth_ + GetAuthStringLength() + 1;
320+
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
321+
path_ = auth_ + GetAuthStringLength();
322+
path_++;
312323
*path_ = '\0';
313324
if (start < len) {
314325
pos2 = start;
@@ -326,7 +337,9 @@ class GenericUri {
326337
}
327338
}
328339
// Look for query (\?([^#]*))?
329-
query_ = path_ + GetPathStringLength() + 1;
340+
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
341+
query_ = path_ + GetPathStringLength();
342+
query_++;
330343
*query_ = '\0';
331344
if (start < len && uri[start] == '?') {
332345
pos2 = start + 1;
@@ -341,7 +354,9 @@ class GenericUri {
341354
}
342355
}
343356
// Look for fragment (#(.*))?
344-
frag_ = query_ + GetQueryStringLength() + 1;
357+
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
358+
frag_ = query_ + GetQueryStringLength();
359+
frag_++;
345360
*frag_ = '\0';
346361
if (start < len && uri[start] == '#') {
347362
std::memcpy(frag_, &uri[start], (len - start) * sizeof(Ch));

0 commit comments

Comments
 (0)