CLang. How to turn on reference to pointer errors

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CLang. How to turn on reference to pointer errors

Deep Majumder via cfe-dev
Hi.

In XCode I declare a function

void func (const Valu & val);

And when I mistakenly pass a pointer instead of a reference to an object, the compiler does not issue an error or warning message. But it generates incorrect code.
How do I enable this error or warning message?

Thanks,
Andrey.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: CLang. How to turn on reference to pointer errors

Deep Majumder via cfe-dev
Can you send a more complete example of what you want to warn?  If you try to pass a pointer to that function, you should get an error that there is no matching call:

https://godbolt.org/z/efh94z

-----Original Message-----
From: cfe-dev <[hidden email]> On Behalf Of Andrey Sharoyko via cfe-dev
Sent: Wednesday, February 17, 2021 7:02 AM
To: [hidden email]
Subject: [cfe-dev] CLang. How to turn on reference to pointer errors

Hi.

In XCode I declare a function

void func (const Valu & val);

And when I mistakenly pass a pointer instead of a reference to an object, the compiler does not issue an error or warning message. But it generates incorrect code.
How do I enable this error or warning message?

Thanks,
Andrey.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: CLang. How to turn on reference to pointer errors

Deep Majumder via cfe-dev
In reply to this post by Deep Majumder via cfe-dev

On Wed, 17 Feb 2021 at 16:02, Andrey Sharoyko via cfe-dev <[hidden email]> wrote:
Hi.

In XCode I declare a function

void func (const Valu & val);

And when I mistakenly pass a pointer instead of a reference to an object, the compiler does not issue an error or warning message.


My money is on Valu being a template parameter.

Csaba
--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformant way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev