Skip to content

Passing references to stack around in order to remove const references pointlessly breaks most builds. #2

@dmiller423

Description

@dmiller423

This is done for most of CryptoBase at the very least.
I've seen this done in the past where it is just a warning, and -Wno-address-of-temporary would turn it off.
In this case, it's not a warning, to pass in a const and then just construct a new BigInt to use it as a reference.. as well as returning a reference to BigInt returned from multiply functions.

CryptoBase.cpp(51,41): error : non-const lvalue reference to type 'BigInt<...>' cannot bind to a temporary of type 'BigInt<...>'
     51 |         return BigInt<N>((void*)&fast_multiply(BigInt<N*2>(val), BigInt<N * 2>(1)));
        |                                                ^~~~~~~~~~~~~~~~
  C:\path\CryptoBase.cpp(57,16): note: in instantiation of member function 'MontgomeryDomain<256>::fast_revert' requested here
     57 |         return fast ? fast_revert(val) : slow_revert(val);
        |                       ^
  C:\path\RSAcipher.cpp(31,16): note: in instantiation of member function 'MontgomeryDomain<256>::revert' requested here
     31 |         return domain.revert(message);
        |                       ^
  C:\path\CryptoBase.h(42,46): note: passing argument to parameter 'left' here
     42 |         BigInt<N * 2>& fast_multiply(BigInt<N * 2> &left, BigInt<N * 2> &right);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions