Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template-related intpromote deprecation message spam #19441

Open
dlangBugzillaToGithub opened this issue May 31, 2018 · 0 comments
Open

Template-related intpromote deprecation message spam #19441

dlangBugzillaToGithub opened this issue May 31, 2018 · 0 comments
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal

Comments

@dlangBugzillaToGithub
Copy link

Sophie reported this on 2018-05-31T11:25:57Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=18926

Description

I downloaded a newer version of DMD and when I went to compile some code, I got a LOT of intpromote deprecation errors. Many of them repeated for the same line, and in one case it was repeated 300+ times for a single line of code.

This is probably because this particular function gets a lot of different template parameters when running unit tests.

/Users/pineapple/Dropbox/Projects/mach.d/mach/math/bits/inject.d(112): Deprecation: integral promotion not done for -cast(ubyte)bit, use '-transition=intpromote' switch or -cast(int)(cast(ubyte)bit)

This was the function causing the error, due to `-(cast(ubyte) bit)`

/// Inject bit into a value where the bit offset is known at compile time.
/// When the `assumezero` template argument is true, the operation is able
/// to be optimized by assuming the targeted bits are all initialized to 0.
auto injectbit(uint offset, bool assumezero = false, T)(
    T value, in bool bit
) if(
    offset < T.sizeof * 8
){
    enum byteoffset = offset / 8;
    enum bitoffset = offset % 8;
    T target = value;
    auto ptr = cast(ubyte*) &target + byteoffset;
    static if(assumezero){
        *ptr |= cast(ubyte) bit << bitoffset;
    }else{
        *ptr ^= (-(cast(ubyte) bit) ^ *ptr) & (1 << bitoffset);
    }
    return target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal
Projects
None yet
Development

No branches or pull requests

1 participant