Commit Graph

13125 Commits

Author SHA1 Message Date
bobsayshilol bb308b3ff4 Add missing guards around push/pop pragmas
This matches all the other places where we silence Windows warnings.
2024-10-27 22:02:34 +00:00
bobsayshilol c1496ab6c0 Fix passing nullptr to args marked as non-null
libstdc++'s |memcpy| and |memset| both state that their inputs should
never be a nullptr since this matches the C spec. Some compilers act on
these hints, so we shouldn't unconditionally call these as it would
signal to the compiler that they can't be nullptrs.

As an example, the following code will always call |do_something()|
when compiled with optimisations since GCC version 4.9:
```
    void clear(void *ptr, int size) {
        memset(ptr, 0, size);
    }
    void example(void *ptr, int size) {
        clear(ptr, size);
        if (ptr != nullptr) do_something();
    }
```
2024-10-27 22:02:34 +00:00
bobsayshilol 4f800a7fda Avoid undefined arithmetic shifting
The result of a left shift on a positive signed integer (Rune) must fit
into an unsigned integer otherwise it's undefined behaviour, as is left
shifting a negative integer by any amount. This code can only be hit if
|x >= 0xf0| and hence a left shift of 31 will always be undefined
unless the input is 0 or 1.

To avoid hitting this we can instead extend the lowest bit to be the
mask if we assume that ints are 2's complement, which we already do
elsewhere. This generates identical code in testing on Compiler
Explorer and the Odin test suite passes locally with this change.

Note that the original code would change to be defined behaviour in
C++20, however we are currently build with |-std=c++14| in the build
scripts.
2024-10-27 22:02:34 +00:00
bobsayshilol e67692b066 Avoid member access through nullptr in debug
If |result_count| is 0 then |results| will be a nullptr and hence the
access |results->Tuple| is undefined behaviour. There's already an
early return in the 0 branch so move that to be the first thing so that
we can guarantee that it's not a nullptr.

Note that technically we take the address of the result so it's not
actually dereferencing it, however UBSan doesn't care about that.
2024-10-27 22:02:34 +00:00
bobsayshilol 771d308d64 Fix invalid union access
UBSan spotted that |src->Basic.kind| had a value outside the range of
|BasicKind| due to it actually being a |Type_Pointer|. Since these are
stored in a union there could be cases where the value of |kind| just
so happens to be |Basic_string|, in which case the branch would have
been taken when it shouldn't have been.

To fix this simply check that it's a |Type_Basic| before treating it as
a |Basic|.
2024-10-27 21:24:36 +00:00
gingerBill 1f187adff4 Merge pull request #4416 from Yawning/fix/4413
src/big_int.cpp: Use square-multiply for exponentiation
2024-10-27 12:13:40 +00:00
gingerBill 35d818bb4e Fix possible leak in recursive filepath.glob 2024-10-27 12:10:10 +00:00
gingerBill f32e27d2e4 Fix bug caused due to incorrect type checking looking for context not defined in a context 2024-10-27 11:10:55 +00:00
Laytan Laats 69d375705e fix the typeid type kind of a typeid being set to Typeid_Invalid 2024-10-27 01:11:44 +02:00
Laytan Laats 44eef21997 wgpu: add missing JS impl for RenderPassEncoderSetBlendConstant 2024-10-26 22:41:52 +02:00
Laytan Laats bd38b4839c sys/wasm/js: add set_element_style 2024-10-26 22:41:14 +02:00
Laytan Laats 4608d26e6e encoding/cbor: fix skipping of ignored/missing fields in struct unmarshal 2024-10-26 22:39:46 +02:00
Laytan 1e3a924e11 Merge pull request #4420 from laytan/cbor-better-handling-of-mismatch-in-struct-and-binary-fields
encoding/cbor: handle binary having more fields than the struct by discarding
2024-10-26 17:14:44 +02:00
Jeroen van Rijn 831558a7c2 Merge pull request #4419 from laytan/rand-choice-enum-non-contiguous
math/rand: support non-contiguous enums in choice_enum
2024-10-25 23:46:05 +02:00
Laytan Laats bb4fc9979a math/rand: support non-contiguous enums in choice_enum 2024-10-25 20:41:57 +02:00
Laytan Laats 793ef6012b encoding/cbor: handle binary having more fields than the struct by discarding 2024-10-25 20:37:55 +02:00
Laytan 3b6ed2164b Merge pull request #4399 from laytan/wgpu-improvements
wgpu: take version check out of @init, use C cc when appropriate
2024-10-25 20:15:15 +02:00
Laytan 0b8e98febe Merge pull request #4398 from laytan/image-misuse-panic
image: add panic when load is called without any registered loaders
2024-10-25 20:05:32 +02:00
gingerBill 4bde87de8f Merge pull request #4418 from laytan/check-packed-on-all-loads
check packed load and set alignment on all loads, not just lb_emit_load
2024-10-25 14:35:32 +01:00
Laytan Laats bcf2b93c6e quote the dsymutil argument
Fixes #4417
2024-10-25 15:34:59 +02:00
Laytan Laats da1e09c95d check packed load and set alignment on all loads, not just lb_emit_load 2024-10-25 15:23:15 +02:00
Yawning Angel 61795232f4 src/big_int.cpp: Use square-multiply for exponentiation
For utterly unrealistic constant sizes, this still crashes on my system,
but it crashes fast due to the OOM killer, and people using rediculously
large exponents get what they deserve.
2024-10-25 11:46:47 +09:00
gingerBill f047f804f6 Merge pull request #4402 from Lperlind/utf16_rune_count
core/unicode/utf16: add rune_count proc
2024-10-23 15:25:21 +01:00
gingerBill 33cc671302 Merge pull request #4403 from tf2spi/issue-4390-fix
Fix #4390 by assigning invalid entity type
2024-10-23 15:25:06 +01:00
gingerBill c5ae7daecd Merge pull request #4404 from tf2spi/issue-4395-fix
Fixes #4395 by not assuming simd returns val
2024-10-23 15:24:59 +01:00
gingerBill 8cba4aa1c3 Merge pull request #4410 from tf2spi/issue-4397-fix
Fix magnitude check in parse_f64_prefix
2024-10-23 15:24:48 +01:00
gingerBill 70bff68f69 Merge pull request #4408 from Lperlind/cache
cached.cpp: Improve internal cached robustness
2024-10-23 15:15:58 +01:00
Misomosi a9f2271a90 Fix magnitude check in parse_f64_prefix 2024-10-22 21:27:39 -04:00
laytan 50597e8691 fix erronous updating alignment of external global 2024-10-22 17:34:49 +02:00
Jeroen van Rijn 00ec862b63 Merge pull request #4335 from colrdavidson/datetime_tz
Add Timezone Support to Odin
2024-10-22 10:18:38 +02:00
Lucas Perlind 28b26043fb cached.cpp: Improve internal cached robustness
Do not memory map files; Windows cannot write to a file that is memory
mapped.
Write cache after llvm building. This ensures the cache won't have a
false positive if llvm fails.
2024-10-22 18:05:01 +11:00
Colin Davidson d8696badb6 add better comment about freebsd hacks 2024-10-21 21:58:32 -07:00
Colin Davidson 9e00d610c8 Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-10-21 21:49:19 -07:00
Colin Davidson d393d3292f Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-10-21 21:48:58 -07:00
Misomosi 6ef915c312 Fixes #4395 by not assuming simd returns val 2024-10-20 22:51:39 -04:00
Misomosi 01c7380df8 Fix #4390 by assigning invalid entity type 2024-10-20 22:45:30 -04:00
Lucas Perlind 66c53a1174 core/unicode/utf16: add rune_count proc
This returns the number of runes in a u16 slice
2024-10-21 08:29:07 +11:00
Laytan 7c1922b0a7 Merge pull request #4401 from tgolsson/ts/cbor-unmarshal-dynarray
cbor: fix capacity and ptr calculation for dynarray unmarshal
2024-10-20 21:40:05 +02:00
Tom Solberg 90a0c834bb cbor: fix capacity and ptr calculation for dynarray unmarshal 2024-10-20 21:27:16 +02:00
Laytan Laats c8ed499293 image: add panic when load is called without any registered loaders 2024-10-20 18:41:10 +02:00
Laytan Laats 62922a421c wgpu: take version check out of @init, use C cc when appropriate 2024-10-20 18:40:17 +02:00
Laytan Laats 9f609dd740 odin/parser: fix offsets of value declarations
Fixes #4356
2024-10-19 20:02:39 +02:00
gingerBill b6cbdf7c54 Merge pull request #4370 from IllusionMan1212/allow-e000-codepoint
fix(core:{odin,c}/tokenizer): Don't error on valid \uE000 codepoint
2024-10-19 18:12:08 +01:00
Laytan Laats e79f94ca5e encoding/json: fix leak when string is unmarshalled into non-string field
Fixes #4391
2024-10-19 17:08:24 +02:00
Laytan Laats b82f8df5f5 possibly fix not having shared dir in recent windows releases
Probably caused by https://github.com/actions/upload-artifact/issues/602
Possibly fixes #4384
2024-10-17 18:05:37 +02:00
Laytan 2141299d2b Merge pull request #4376 from Barinzaya/sysinfo-avx512
core:sys/info AVX-512 CPU Features
2024-10-16 19:46:01 +02:00
Laytan 1cb93efe8a Merge pull request #4382 from Barinzaya/time_32b_linux_overflow
Fixed core:time overflows on 32-bit Linux
2024-10-16 18:27:28 +02:00
Barinzaya 142e7d6b52 Fixed time overflows that occur when running in a 32-bit Linux target. 2024-10-15 13:43:28 -04:00
Barinzaya 872a29752c Renamed and trimmed AVX-512 features in sys/info.
Removed underscores from the AVX-512 names in `CPU_Feature` to make them match their equivalent LLVM target features. Removed 4FMAPs and 4VNNIW as there aren't matching LLVM target features.
2024-10-15 05:21:35 -04:00
Laytan Laats 7989d512a0 add macos 15.0.1 to odin report and core/sys/info 2024-10-14 16:19:03 +02:00