Opened 4 years ago

#13583 new Bugs

quantities can be assigned from cmath sqrt result, but not initialized

Reported by: edaskel@… Owned by: Matthias Schabel
Milestone: To Be Determined Component: units
Version: Boost 1.67.0 Severity: Problem
Keywords: Cc:

Description

The cmath functions are very helpful in letting me perform math on quantities, but I ran across an inconsistency. Code like:

    quantity<wavenumber, float> x, y;
    quantity<wavenumber, float> foo = sqrt(x*x + y*y);

fails to compile (with an "error: conversion from..."). The workaround is to use an assignment instead:

    quantity<wavenumber, float> foo;
    foo = sqrt(x*x + y*y);

It seems odd to have this restriction (and it's certainly undocumented) so I suspect it is a bug.

Attachments (1)

repro.cpp (520 bytes ) - added by edaskel@… 4 years ago.
minimal test case

Download all attachments as: .zip

Change History (1)

by edaskel@…, 4 years ago

Attachment: repro.cpp added

minimal test case

Note: See TracTickets for help on using tickets.