Skip to content

A hex int literal passed as a macro parameter forgets its identity and gets stringify!-ed as a decimal int literal #33047

@nodakai

Description

@nodakai

Minor papercut:

macro_rules! m {
    ($e: expr) => (stringify!($e))
}

fn main() {
    println!("{:?}", stringify!(1 +1));
    println!("{:?}",         m!(1 +1));
    println!("{:?}", stringify!(0xff));
    println!("{:?}",         m!(0xff));
    println!("{:?}", stringify!(1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001));
    println!("{:?}",         m!(1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001));
}
"1 + 1"
"1 + 1"
"0xff"
"255"
"1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
"1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"

0xff is converted into 255 while 1.000....1 isn't (the delta from 1.0 is clearly smaller than IEEE854 double's machine epsilon)

May or may not be related to #28415

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions