Skip to content

Dependencies between constants aren't tracked correctly. #592

@emilio

Description

@emilio

See #587 (comment)

This is not an issue for C mode because we use macros which are terrible but don't have this problem.

But for C++, where we try to generate "proper" constants, this can cause compilation errors.

This test-case:

pub const B: usize = 4;
pub const A: usize = B + 1;

Generates:

#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

static const uintptr_t A = (B + 1);

static const uintptr_t B = 4;

Which fails to compile like:

t.cc:7:29: error: ‘B’ was not declared in this scope
    7 | static const uintptr_t A = (B + 1);
      |

It seems at least we should preserve the const definition order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions