Bug 15073 - Fix building Samba with gcc 12
Summary: Fix building Samba with gcc 12
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build (show other bugs)
Version: 4.16.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-23 11:37 UTC by Andreas Schneider
Modified: 2022-07-22 00:22 UTC (History)
3 users (show)

See Also:


Attachments
patch for 4.16 (1.32 KB, patch)
2022-05-23 11:39 UTC, Andreas Schneider
no flags Details
patch for 4.15 (1.32 KB, patch)
2022-05-23 11:42 UTC, Andreas Schneider
no flags Details
patch for 4.16 and 4.15 (3.13 KB, patch)
2022-07-19 13:04 UTC, Andreas Schneider
asn: review? (metze)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schneider 2022-05-23 11:37:27 UTC
Patch will follow ...
Comment 1 Andreas Schneider 2022-05-23 11:39:08 UTC
Created attachment 17296 [details]
patch for 4.16
Comment 2 Andreas Schneider 2022-05-23 11:42:49 UTC
Created attachment 17298 [details]
patch for 4.15
Comment 3 Stefan Metzmacher 2022-05-23 12:14:27 UTC
Comment on attachment 17296 [details]
patch for 4.16

Shouldn't we fix the code?
Comment 4 Andreas Schneider 2022-05-23 13:27:01 UTC
The code is correct, it has

if (count >= 1) {
    max_n[count]

    ...
}

Just gcc is not able to detect this. If you want to fix it you need to fully rewrite the code.
Comment 5 Andreas Schneider 2022-05-23 13:27:36 UTC
I've talked to gcc people, they suggested just this solution.
Comment 6 Volker Lendecke 2022-05-23 15:00:54 UTC
Moreover, this is the one in lib/util. source3/lib/util has its own flavor that does SMB_MALLOC....
Comment 7 Andreas Schneider 2022-05-24 08:08:50 UTC
The bug didn't go away when I talloc'ed max_n.
Comment 8 Stefan Metzmacher 2022-07-15 08:39:15 UTC
Don't we need check if the compiler supports the option?

And we may want to split out a SAMBA_SUBSYSTEM for the affected file
we don't want to allow new warnings in other files
Comment 9 Stefan Metzmacher 2022-07-15 09:05:04 UTC
At least v4-16-test + the patches from bug #15095 build fine
on Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)

Can we drop this and revert 00e31d9d069db9fd36bf2e668047921a5645351d in master?
Comment 10 Samba QA Contact 2022-07-19 12:18:03 UTC
This bug was referenced in samba master:

f340b8847242a7d6ae81e37118c6a6d352fb2d66
Comment 11 Andreas Schneider 2022-07-19 13:04:32 UTC
Created attachment 17429 [details]
patch for 4.16 and 4.15