diff options
author | Bruce Dawson <brucedawson@chromium.org> | 2017-10-26 14:17:45 -0700 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2017-10-26 22:25:57 +0000 |
commit | 73d2773f9f455944e2cec1c0ad3ea9f5e6705361 (patch) | |
tree | 15a5b288c867080474d7130de93741d236e4859a | |
parent | Roll src/src/third_party/lss/ a91633d17..e6527b0cd (1 commit) (diff) | |
download | breakpad-73d2773f9f455944e2cec1c0ad3ea9f5e6705361.tar.xz |
Avoid skipping an initializer with a goto
C++ doesn't allow skipping initialization with a goto. This means that
this code is illegal:
void func(bool b) {
if(b) goto END;
int value = 0; //error C2362 with /permissive-
//... value used here
END:
return;
}
Adding an extra scope makes the code legal. This problem is only
detected with /permissive- but now that compiling with this
switch is practical we might as well stay /permissive- clean:
https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/
Note that compiling /permissive- clean only works with the 10.0.16299.0
SDK which currently has other issues...
Bug: 773476
Change-Id: I54e64aaef46d70a817cf7da272f76d9ae5f6a6f7
Reviewed-on: https://chromium-review.googlesource.com/740287
Reviewed-by: Mark Mentovai <mark@chromium.org>
-rw-r--r-- | src/common/windows/pdb_source_line_writer.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc index 31920ba7..363ce7d8 100644 --- a/src/common/windows/pdb_source_line_writer.cc +++ b/src/common/windows/pdb_source_line_writer.cc @@ -1166,12 +1166,15 @@ int PDBSourceLineWriter::GetFunctionStackParamSize(IDiaSymbol *function) { goto next_child; } - int child_end = child_register_offset + static_cast<ULONG>(child_length); - if (child_register_offset < lowest_base) { - lowest_base = child_register_offset; - } - if (child_end > highest_end) { - highest_end = child_end; + // Extra scope to avoid goto jumping over variable initialization + { + int child_end = child_register_offset + static_cast<ULONG>(child_length); + if (child_register_offset < lowest_base) { + lowest_base = child_register_offset; + } + if (child_end > highest_end) { + highest_end = child_end; + } } next_child: |