https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119990

--- Comment #3 from Connor Nolan <connor24nolan at live dot com> ---
This was reduced from a file in a project I was working on:

https://godbolt.org/z/T4ozTPx3E

#include <string>
#include <cstdio>

// Config
struct RebornConfig {
    // General
    struct {
        std::string version;
        std::string author;
        std::string arch;
    } general;

    // App Information
    struct {
        std::string title;
        std::string id;
        std::string name;
    } app;

    // Extra Options
    struct {
        std::string skin_server;
        std::string discord_invite;
        std::string repo_url;
    } extra;

    // Documentation
    struct {
        std::string base;
        std::string getting_started;
        std::string changelog;
    } docs;

    // Internal
    struct {
        bool use_prebuilt_armhf_toolchain;
        std::string sdk_dir;
    } internal;

    // Packaging
    enum class PackagingType {
        NONE,
        APPIMAGE,
        FLATPAK
    };
    PackagingType packaging;
    struct {
        std::string json_url;
        std::string version_placeholder;
        std::string download_url;
    } appimage;
};

// Process CMake Options
#define MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN 1
static RebornConfig::PackagingType get_packaging_type() {
    const std::string value = "none";
    if (value == "appimage") {
        return RebornConfig::PackagingType::APPIMAGE;
    } else if (value == "flatpak") {
        return RebornConfig::PackagingType::FLATPAK;
    } else {
        return RebornConfig::PackagingType::NONE;
    }
}
static RebornConfig::PackagingType packaging_type = get_packaging_type();

// Main Config
const RebornConfig reborn_config = {
    // General
    .general = {
        .version = "3.0.0",
        .author = "TheBrokenRail",
        .arch = "armhf",
    },

    // App Information
    .app = {
        .title = "Minecraft: Pi Edition: Reborn",
        .id = "com.thebrokenrail.MCPIReborn",
        .name = "minecraft-pi-reborn",
    },

    // Extra Options
    .extra = {
        .skin_server =
"https://raw.githubusercontent.com/MCPI-Revival/Skins/data";,
        .discord_invite = "https://discord.gg/mcpi-revival-740287937727561779";,
        .repo_url =
"https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn";,
    },

    // Documentation
    .docs = {
        .base =
"https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/src/tag/3.0.0/docs/";,
        .getting_started =
"https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/src/tag/3.0.0/docs/GETTING_STARTED.md";,
        .changelog =
"https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases/tag/3.0.0";,
    },

    // Internal
    .internal = {
        .use_prebuilt_armhf_toolchain = MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN == 1,
        .sdk_dir = "lib/minecraft-pi-reborn/sdk",
    },

    // Packaging
    .packaging = packaging_type,
    .appimage = {
        .json_url =
"https://gitea.thebrokenrail.com/api/v1/repos/minecraft-pi-reborn/minecraft-pi-reborn/releases/latest";,
        .version_placeholder = "%VERSION%",
        .download_url =
"https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases/download/%VERSION%/minecraft-pi-reborn-%VERSION%-armhf.AppImage";,
    }
};

I was very confused when this seemingly simple code started yelling at me about
uninitiaized variables.

Reply via email to