Repository: godot
Issue: Some warnings and undefined behavior wehen building godot.
Labels: bug,topic:buildsystem,needs testing

### Tested versions

- Reproducible in 4.3-stable

### System information

Kubuntu 24.04

### Issue description

Got some error when building with these parameters...

```bash
scons -j4 platform=linuxbsd target=editor
```

here is my custom.py...

```python
# Generated using https://godot-build-options-generator.github.io

production = "yes"
optimize = "size"
deprecated = "no"
module_mono_enabled = "yes"

```

```bash
...
[Initial build] Linking Static Library core/libcore.linuxbsd.editor.x86_64.a ...
Ranlib Library core/libcore.linuxbsd.editor.x86_64.a ...
[Initial build] Linking Program bin/godot.linuxbsd.editor.x86_64.mono ...
modules/mono/csharp_script.h:58: warning: type 'struct CSharpScript' violates the C++ One Definition Rule [-Wodr]
   58 | class CSharpScript : public Script {
      | 
./modules/mono/csharp_script.h:58: note: a different type is defined in another translation unit
   58 | class CSharpScript : public Script {
      | 
modules/mono/csharp_script.h:158: note: the first difference of corresponding definitions is field 'pending_reload_instances'
  158 |         HashSet<ObjectID> pending_reload_instances;
      | 
./modules/mono/csharp_script.h:168: note: a field with different name is defined in another translation unit
  168 |         String source;
      | 
thirdparty/icu4c/common/udata.cpp:646: warning: type of 'icudt_godot75_dat' does not match original declaration [-Wlto-type-mismatch]
  646 | extern "C" const DataHeader U_DATA_API U_ICUDATA_ENTRY_POINT;
      | 
thirdparty/icu4c/icudata.gen.h:10: note: 'icudt_godot75_dat' was previously declared here
   10 | extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {
      | 
./modules/mono/csharp_script.h:59: warning: type of '_get_class_namev' does not match original declaration [-Wlto-type-mismatch]
   59 |         GDCLASS(CSharpScript, Script);
      | 
modules/mono/csharp_script.h:59: note: '_get_class_namev' was previously declared here
   59 |         GDCLASS(CSharpScript, Script);
      | 
./modules/mono/csharp_script.h:241: warning: type of 'get_documentation' does not match original declaration [-Wlto-type-mismatch]
  241 |         virtual Vector<DocData::ClassDoc> get_documentation() const override {
      | 
modules/mono/csharp_script.h:241: note: 'get_documentation' was previously declared here
  241 |         virtual Vector<DocData::ClassDoc> get_documentation() const override {
      | 
./modules/mono/csharp_script.h:59: warning: type of 'get_class' does not match original declaration [-Wlto-type-mismatch]
   59 |         GDCLASS(CSharpScript, Script);
      | 
modules/mono/csharp_script.h:59: note: 'get_class' was previously declared here
   59 |         GDCLASS(CSharpScript, Script);
      | 
thirdparty/vulkan/include/vulkan/vulkan_core.h:1431: warning: type 'VkFormat' violates the C++ One Definition Rule [-Wodr]
 1431 | typedef enum VkFormat {
      | 
thirdparty/libktx/lib/vkformat_enum.h:21: note: an enum with different value name is defined in another translation unit
   21 | typedef enum VkFormat {
      | 
thirdparty/vulkan/include/vulkan/vulkan_core.h:1679: note: name 'VK_FORMAT_R16G16_SFIXED5_NV' differs from name 'VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT' defined in another translation unit
 1679 |     VK_FORMAT_R16G16_SFIXED5_NV = 1000464000,
      | 
thirdparty/libktx/lib/vkformat_enum.h:269: note: mismatching definition
  269 |     VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT = 1000288000,
      | 
In member function 'SingleCellular',
    inlined from 'GenNoiseSingle' at ./thirdparty/noise/FastNoiseLite.h:650:34:
./thirdparty/noise/FastNoiseLite.h:1732:33: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
 1732 |                         zPrimed += PrimeZ;
      |                                 ^
./thirdparty/noise/FastNoiseLite.h:1715:46: note: within this loop
 1715 |                     for (int zi = zr - 1; zi <= zr + 1; zi++)
      |                                              ^
./thirdparty/noise/FastNoiseLite.h:1699:33: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
 1699 |                         zPrimed += PrimeZ;
      |                                 ^
./thirdparty/noise/FastNoiseLite.h:1682:46: note: within this loop
 1682 |                     for (int zi = zr - 1; zi <= zr + 1; zi++)
      |                                              ^
./thirdparty/noise/FastNoiseLite.h:1666:33: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
 1666 |                         zPrimed += PrimeZ;
      |                                 ^
./thirdparty/noise/FastNoiseLite.h:1649:46: note: within this loop
 1649 |                     for (int zi = zr - 1; zi <= zr + 1; zi++)
      |                                              ^

```

### Steps to reproduce

Idk I guess just build godot with the same flags as I did.

### Minimal reproduction project (MRP)

NA