Skip to content

Conversation

@walid-git
Copy link
Member

This is just a wrapper around probes pointers comparison, it avoids C-compiler failures like:

error: self-comparison always evaluates to true
error: array comparison always evaluates to false

Fixes: #4410
And should also fix the failing test case in master branch.

nigoroll added a commit that referenced this pull request Nov 28, 2025
This is one of the cases where arrays do not behave like pointers, but besides
the slightly more elaborate syntax I think a compound literal is what we
intended all along, just using the array syntax as a convenience.

Fixes #4410

Ref #4418
@nigoroll
Copy link
Member

Not sure if there are other good reasons for the VPI function, but since 7a88cab the main motivation should be gone?

@nigoroll
Copy link
Member

Ah, I see it now: The error: self-comparison always evaluates to true [-Werror,-Wtautological-compare] remains with the vtc added here.

@nigoroll
Copy link
Member

nigoroll commented Nov 28, 2025

I wonder if we should catch the tautology/contradiction in vcc: for (sym == sym) and (sym != sym), we could just emit true/ false. This could potentially also cover other cases

edit: Or should we just not do this and keep the compiler error, because such a tautology might be a mistake?

nigoroll pushed a commit to nigoroll/varnish-cache that referenced this pull request Nov 28, 2025
Committer edited: Taken from varnishcache#4418
@walid-git
Copy link
Member Author

Bugwash:

  • Turn VPI_Probe_Cmp into a generic VPI_Ptr_Cmp that can be used by other types as well.
  • Add a new VCL syntax: unused <symbol>; that generates a (void)<rname>; line in C, avoiding the need for if (p1 == p1) type of workarounds.

This is just a wrapper around pointers comparison, it avoids
C-compiler failures like:

 error: self-comparison always evaluates to true
 error: array comparison always evaluates to false

Fixes: varnishcache#4410
Copy link
Member

@nigoroll nigoroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my fetish asks for a static inline, but other than that +1

nigoroll added a commit that referenced this pull request Dec 3, 2025
The compound literal is not supported as a constant expression by older
compilers, and trying to avoid it (by defining the probe as a struct literal and
then taking a pointer to it) comes with another set of problems around
unreferenced symbols.

So all in all I must say that the single element array "hack" has many more
benefits than were apparent to me and I now changed my mind that they actually
are, objectively, the better solution - except for the fact that arrays can not
be compared, but that will be fixed with #4418.

This reverts commit 7a88cab.

Ref #4418
Ref #4410
@walid-git walid-git merged commit 09f8b34 into varnishcache:master Dec 3, 2025
10 checks passed
@walid-git walid-git deleted the probe_cmp branch December 3, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vcl: Cannot have unreferenced probes

3 participants