Math.Pow(-1, 2) == -1 in Windows 11 Insider build
126 comments
·July 2, 2025Someone
coldpie
What do you disagree with, exactly? The bug is in an underlying library, so it should be reported to that library. That all seems correct to me, I don't see what there is to disagree with there.
The problem with the comment is it does not make ownership of the next steps clear. The maintainer should've either taken the ball ("I will report this to...") or made it clear that the reporter should hold the ball ("We can't fix this here. You should report it to..."). Instead they used the passive voice ("The issue should be reported to..."), which means no one owns it, which means it won't be done, which is a bad way to handle a bug report.
nkrisc
If your software has a bug, it’s your bug. If the root cause of the bug in your software comes from a direct call into some dependency, that’s immaterial to the users of your software. Your software is incorrect, so your software has a bug.
How you choose to resolve it is up to you. You might implement a fix in your code to handle the bug case until the dependency is fixed.
coldpie
Of course. They chose to resolve it by saying the underlying software should be fixed. That seems perfectly fine to me.
blueplanet200
This issue is the word "instead".
Instead means "this isn't our bug, it's the underlying library."
The libraries you rely on are part of your product. You own the issues that bubble up from them.
A much much better reply for the maintainer would've been: "The root cause looks to be X, I'll submit a ticket and make sure a fix makes it into our build."
Sankozi
Unless the documentation says that Math.Pow just returns the result of calling some other code (it doesn't do that), the bug is both in the Math.Pow and underlying library. It should be reported and tracked in both.
dylan604
But should it be the responsibility of the person reporting the bug in Math.Pow, or the devs maintaining Math.Pow sees it is part of the underlying library and makes the report?
snickerbockers
>The bug is in an underlying library
they didn't test that they just assumed that since they call a library function the library function must be the root-cause. This is classic bug-punting.
Y_Y
If you can't hunt it, punt it!
mdemare
If a library has a flaw that big, it is a bug to use that library.
coldpie
You are going to have a very short, frustrating career in software if that's your position. Bugs happen, report them, get them fixed, chill out, and don't be a dick.
scott_w
> What do you disagree with, exactly?
OP said it quite clearly and so did you: that it's the reporter's job. It's the maintainer's job to put in the bug report now.
coldpie
> OP said it quite clearly and so did you: that it's the reporter's job.
I don't agree that it was stated clearly. That's the whole point of my comment. Leaving it unclear is bad, tasks should always have an unambiguous owner.
dist-epoch
Bro is a Microsoft employee. He should say "thank you for the bug report", and open a bug in the underlying library if that is the correct place.
Bug reporter might not care that much and not bother opening another bug report, and this looks like a pretty bad bug.
JohnFen
This. And that's how it should work whether or not it's a Microsoft application.
Users report bugs to the team working on the user application. If the bug is actually in a component that application uses, then it's that team's responsibility to report it upstream, not the user's.
EE84M3i
It was clarified on the thread that that person was NOT a Microsoft employee and just a volunteer. That completely changed my perspective on the situation.
coldpie
I agree that's the ideal solution in a vacuum, but I don't know this person's responsibilities regarding the projects in question, so I don't want to make assumptions about what they can or should do.
wat10000
It's going to be interpreted, and is probably meant, as saying that the person who filed the bug should close this report and open a new one in the right place.
mort96
Since the comment you responded to already complained about use of passive voice...
It's going to be interpreted BY WHOM to say that? Other .NET developers? Yeah, maybe, at least some of them. By the submitter of the original bug? No idea, I can't read their mind.
snickerbockers
reminds me of when i had a job working on a company that had its own OS (which was an extremely outdated proprietary FreeBSD fork) and we spent more time arguing about who's fault everything was than solving problem. I used to love low-level programming until I realized that in the corporate world (i assume/hope this does not apply to open-source communities) the people who get ahead are the people who can master the art of jettisoning responsibility so that they're always the guy who just implemented the hot new feature and management thinks the people who actually have to make this stuff work are all incompetent and lazy because it takes 2-4 weeks to untangle all the heap corruption and race condition bugs and ultimately come up with a meager 10-line patch to prevent the kernel panic.
jug
Just posting to say everything is fine. It works to report this way too, via .NET maintainers. It is very common to do this as well.
https://github.com/dotnet/runtime/issues/117233#issuecomment...
You’re quoting a community contributor and this is not a firm stance held by MS themselves. He should probably not have posted that because it’s misleading. They even have a tag to triage these kinds of issues.
reverendsteveii
That "instead" later got swapped for "in addition" in a clarifying comment that makes this feel a lot less gross afaic
charcircuit
>It’s not the job of a bug reporter to figure that out
The comment isn't blaming the reporter for not doing that.
mort96
The comment isn't clear. It can be read as blaming the reporter, or it can be read as telling someone else who works on .NET (who?) to open a bug report against UCRT.
JohnFen
It reads the opposite to me. I absolutely read it as "you reported this to the wrong people".
wat10000
It is at the very least putting the onus on the reporter for correcting it, which is not how it should be done here.
neonsunset
[dead]
Alifatisk
> If you need to contact us better, joining the osu! Discord server would be best
I really dislike how Discord is slowly eating up the web and being used as the primary channel for communication, when most of the community resources resides in their Discord, it makes it hard for me to find relevant information through the web thanks to Discords lock-in
jjice
Discord also has a kind of culture I don't love connecting to for misc environments. I'm sure most are fine, but I've joined software related discords where people are having oddly NSFW chats. They've always been in different channels, but why does this software project need a NSFW channel?
I think it's _too_ social for bug reports and questions. I'd prefer a forum or GitHub issues for that kind of thing.
Or maybe I'm just getting old.
null
debo_
I've heard people moan that software is getting exponentially worse. Maybe they're right after all /joke
lucaslazarus
Clearly the issue is real and not imaginary
Tepix
There are no imaginary numbers insolved in this bug, however.
bee_rider
Although, if (-1)^2=-1, then the question that generates imaginary numbers doesn’t even come up, right? Clearly the square root of a negative is well defined.
hinkley
Tell that to the compiler.
ARob109
I see what you did there
sksrbWgbfK
You're joking but we went from the Ada "contracts and pre/post conditions" to the ReactJS monstrosities instead on improving the whole thing and being more strict.
monkeyelite
I think it has more to do with the people than the tools.
pas
that's what the comment means we as people went from picking Ada to ReactJS
of course we also went from having no Rust and no TypeScript and only a few hundred thousand semi-academic people having some knowledge of programming to hundreds of millions of people doing some tutorial/bootcamp/cert/degree, or even built something, or actively learns, or right now works as a professional programmer.
(un)fortunately Ada was not able to grow to became the default tool for all these jobs that all those millions of people did or wanted to do when they did/do programming.
JS/ECMAScript is evolving, things are getting better!
H8crilA
An exponentially astute observation.
tantalor
Don't be so negative.
fn-mote
I really want to know how this could have passed CI testing.
(Comments blame it on UCRT, not .NET but… that doesn’t matter much to me.)
AndroTux
“Oh, I can see the test is failing. Let me fix this by adjusting the test to expect the currently returned value.”
This is unfortunately an actual quote I got from Claude Code after having it write a unit test for me.
It ended up mocking the entire method it was supposed to test, resulting in the unit test essentially only testing itself.
cjbgkagh
Sounds very human. I experienced some junior devs who grew up with TDD and would often just tweak their code to pass their tests without stopping to understand their code at a fundamental level - essentially development through trial and error. Since they were also the ones writing the tests the core assumptions went into both and because they did so without thinking they were more likely to have errors. The test being wrong was more than likely and in those cases it would make sense to fix the test output.
pydry
TDD only really works if the test in some sense mirrors the specification.
Sometimes people manage it in which case it resembles a mini superpower but mostly they do not.
If it mirrors the spec then few people would change it to be wrong to make the test work.
hinkley
Because AI is learning from humans and half of coders suck.
tempodox
Now I understand how people who let LLMs write their code for them come to believe it boosts their productivity. /s
null
sksrbWgbfK
I would definitely expect some kind of test like -1^2 == 1 for such an important SDK, even more if it impacts C++ too. Well, they hopefully have now written this test.
TZubiri
(Please hold while we transfer you to the UCRT department, your call is very important to us)
dist-epoch
Maybe this is a new optimization, and AI wrote the tests.
gosub100
Maybe its a bug in their telemetry? They have to pass the parameters to azure to data-mine customer activity and azure accidentally returned the incorrect result.
CodesInChaos
I'm surprised that an optimizing compiler lets this case even hit the general `pow` runtime function. I'd have expected it to replace this call by `x * x` so it doesn't hit the expensive general `pow` function.
I find it strange as well that no unit test caught this. Squaring a negative number is definitely a case I'd expect to be covered. Perhaps compiler optimization made this case work in the unit test, allowing the runtime function to break? And then it broken in .net where the JIT compiler is dumber than the C++ compiler?
smidgeon
Off by 2, not so bad
nkrisc
Looks like complex numbers are much simplified on Windows 11.
nottorp
They convert the arguments to complex, do it right and the error is at the back conversion step!
shthed
Anyone got a link to the actual OS bug that caused this? I would love to see an explanation of how it happened and what the code looked like.
The_suffocated
No idea why this happened. Perhaps Math.Pow(x,y) was implemented as 2**(y*log2(x)) without writing special code to deal with the case where x is negative real and y is integer?
rich_sasha
In fairness, the general power function might well be complicated. Dealing with fractional base and exponent, signs (-1^2 makes sense but -1^0.5 doesn't in real numbers). I don't know how that works in code but I can see how this gremlin sneaks in.
I don't see how it gets past the test suite though.
comrade1234
How does the OS still function with a basic bug like this?
mmis1000
Due to how windows manage dependencies, you can have different versions of same library all the way back to windows xp days. It's not necessary other software on the computer will hit the bug on this version of library.
vermilingua
I don’t think there is much systems code that needs an exponent of -1, maybe none that needs exponents at all (aside from 2^n, which has opcodes, not C functions)
terminalbraid
The bug is for an exponent of 2. The base is -1.
CodesInChaos
Most critical OS functionality will use integers, not floats. And I'd expect most programmers to write squaring a float as `x * x`.
dvh
There was an article some time ago where someone ran doom with progressively more incorrect value of pi
wat10000
What critical OS functionality would this break?
null
tempodox
Should we be surprised that Microsoft doesn't know maths? Was the code for that generated by an LLM?
I disagree with the comment
“Both Math.Pow and std::pow invokes the pow function in UCRT, which is shipped with Windows. The issue should be reported to MSVC instead”
It’s not the job of a bug reporter to figure that out and to verify that nothing goes wrong in setting up stuff for invoking that function or in getting its output back into the C# world.
That’s even more true because the dynamic nature of .NET code makes it far from easy to verify by inspection that that function is just calling the pow function in UCRT. The C# compiler might do constant folding wrong and there might be several ways in which the runtime compiles the CLR code (fast compilation to start running it quickly, slower compilation that produces faster code later if it turns out to be called a lot, etc)