diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-04-15 17:44:00 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-04-15 17:49:58 +0530 |
commit | 9a9654c4bdfeeab78b602a27615ab1845b7ba383 (patch) | |
tree | 356afdd6d1d900d76f2f95945e8387a67a74fedf /mesonbuild/compilers.py | |
parent | 563b978bf268ef9f6bf717929b472bc078fe95de (diff) | |
download | meson-9a9654c4bdfeeab78b602a27615ab1845b7ba383.zip meson-9a9654c4bdfeeab78b602a27615ab1845b7ba383.tar.gz meson-9a9654c4bdfeeab78b602a27615ab1845b7ba383.tar.bz2 |
Fix off-by-one in cross_sizeof and cross_alignment on MSVC
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 8dee468..e9a798d 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -596,6 +596,10 @@ int temparray[%d-sizeof(%s)]; for i in range(1, 1024): code = templ % (prefix, i, element) if self.compiles(code, extra_args): + if self.id == 'msvc': + # MSVC refuses to construct an array of zero size, so + # the test only succeeds when i is sizeof(element) + 1 + return i - 1 return i raise EnvironmentException('Cross checking sizeof overflowed.') @@ -633,6 +637,10 @@ int testarray[%d-offsetof(struct tmp, target)]; for i in range(1, 1024): code = templ % (typename, i) if self.compiles(code, extra_args): + if self.id == 'msvc': + # MSVC refuses to construct an array of zero size, so + # the test only succeeds when i is sizeof(element) + 1 + return i - 1 return i raise EnvironmentException('Cross checking offsetof overflowed.') |