Skip to content

Warnings with gcc 15.2 #20242

@monnerat

Description

@monnerat

I did this

Compiling the following minimal program with gcc 15.2:

#include <stdint.h>
#include "curl/curl.h"

int
main()
{
	uint32_t auth = CURLAUTH_ANY;

	auth &= CURLAUTH_ANYSAFE;
}

issues the following warning:

warning: conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’} changes value from ‘18446744073709551599’ to ‘4294967279’ [-Woverflow]
    7 |         uint32_t auth = CURLAUTH_ANY;
      |                         ^~~~~~~~~~~~

Using options -Wno-overflow -Wconversion:

warning: conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’} changes the value of ‘18446744073709551598’ [-Wconversion]
    9 |         auth &= CURLAUTH_ANYSAFE;
      |                 ^~~~~~~~~~~~~~~~

IMO, curl.h computed constants should not have bits set outside their normal type domain. This is true at least for negated bit masks: aka:

#define CURLAUTH_ANY          (~CURLAUTH_DIGEST_IE)
#define CURLAUTH_ANYSAFE      (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
#define CURLSSH_AUTH_ANY    ~0L       /* all types supported by server */

The case of
#define CURLPROTO_ALL (~0L) /* enable everything */
is unclear as long as we do not yet define protocol numbers > 31.

I expected the following

No warnings.

curl/libcurl version

8.15.0

operating system

Fedora 43

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions